suppressionServiceInutile #37
Merged
clement.chieu
merged 12 commits from suppressionServiceInutile
into master
1 year ago
@ -1,14 +0,0 @@
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public interface IInquiryDataService : IInquiryService<InquiryDTO>
|
||||
{
|
||||
public IEnumerable<InquiryDTO> GetInquiries(int page, int number, InquiryOrderCriteria orderCriteria);
|
||||
public InquiryDTO GetInquiryById(int id);
|
||||
public InquiryDTO GetInquiryByTitle(string title);
|
||||
public bool DeleteInquiry(int id);
|
||||
public InquiryDTO UpdateInquiry(int id, InquiryDTO inquiry);
|
||||
public InquiryDTO CreateInquiry(string title, string description, bool isUser);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public interface ILessonDataService : ILessonService<LessonDTO>
|
||||
{
|
||||
public IEnumerable<LessonDTO> GetLessons(int page, int number, LessonOrderCriteria orderCriteria);
|
||||
public LessonDTO GetLessonById(int id);
|
||||
public LessonDTO GetLessonByTitle(string title);
|
||||
public bool DeleteLesson(int id);
|
||||
public LessonDTO UpdateLesson(int id, LessonDTO lesson);
|
||||
public LessonDTO CreateLesson(string title, string lastPublisher, DateOnly? lastEdit);
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public interface IParagraphDataService : IParagraphService<ParagraphDTO>
|
||||
{
|
||||
public IEnumerable<ParagraphDTO> GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria);
|
||||
public ParagraphDTO GetParagraphById(int id);
|
||||
public ParagraphDTO GetParagraphByTitle(string title);
|
||||
public bool DeleteParagraph(int id);
|
||||
public ParagraphDTO UpdateParagraph(int id, ParagraphDTO paragraph);
|
||||
public ParagraphDTO CreateParagraph(string title, string content, string info, string query, string comment, int lessonId);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public interface ISuccessDataService : ISuccessService<SuccessDTO>
|
||||
{
|
||||
public IEnumerable<SuccessDTO> GetSuccesses(int page, int number, SuccessOrderCriteria orderCriteria);
|
||||
public SuccessDTO GetSuccessByUserId(int id);
|
||||
public SuccessDTO GetSuccessByInquiryId(int id);
|
||||
public bool DeleteSuccess(int id);
|
||||
public SuccessDTO UpdateSuccess(int id, SuccessDTO success);
|
||||
public SuccessDTO CreateSuccess(int userId, int inquiryId, bool isFinished);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public interface IUserDataService : IUserService<UserDTO>
|
||||
{
|
||||
public IEnumerable<UserDTO> GetUsers(int page, int number, UserOrderCriteria orderCriteria);
|
||||
public UserDTO GetUserById(int id);
|
||||
public UserDTO GetUserByUsername(string username);
|
||||
public bool DeleteUser(int id);
|
||||
public UserDTO UpdateUser(int id, UserDTO user);
|
||||
public UserDTO CreateUser(string username, string password, string email, bool isAdmin);
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
using DbContextLib;
|
||||
using Shared.Mapper;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public class InquiryDataService : IInquiryDataService
|
||||
{
|
||||
private UserDbContext DbContext { get; set; }
|
||||
|
||||
public InquiryDataService(UserDbContext context)
|
||||
{
|
||||
DbContext = context;
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public IEnumerable<InquiryDTO> GetInquiries(int page, int number, InquiryOrderCriteria orderCriteria)
|
||||
{
|
||||
IQueryable<InquiryEntity> query = DbContext.Inquiries.Skip((page - 1) * number).Take(number);
|
||||
switch (orderCriteria)
|
||||
{
|
||||
case InquiryOrderCriteria.None:
|
||||
break;
|
||||
case InquiryOrderCriteria.ByTitle:
|
||||
query = query.OrderBy(s => s.Title);
|
||||
break;
|
||||
case InquiryOrderCriteria.ByDescription:
|
||||
query = query.OrderBy(s => s.Description);
|
||||
break;
|
||||
case InquiryOrderCriteria.ByIsUser:
|
||||
query = query.OrderBy(s => s.IsUser);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
var inquiries = query.ToList();
|
||||
return inquiries.Select(s => s.FromEntityToDTO());
|
||||
}
|
||||
|
||||
public InquiryDTO GetInquiryById(int id)
|
||||
{
|
||||
var inquiryEntity = DbContext.Inquiries.FirstOrDefault(i => i.Id == id);
|
||||
if (inquiryEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'enquête", nameof(id));
|
||||
}
|
||||
|
||||
return inquiryEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public InquiryDTO GetInquiryByTitle(string title)
|
||||
{
|
||||
var inquiryEntity = DbContext.Inquiries.FirstOrDefault(i => i.Title == title);
|
||||
if (inquiryEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'enquête", nameof(title));
|
||||
}
|
||||
|
||||
return inquiryEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public InquiryDTO CreateInquiry(string title, string description, bool isUser)
|
||||
{
|
||||
var newInquiryEntity = new InquiryDTO(title, description, isUser);
|
||||
DbContext.Inquiries.Add(newInquiryEntity.FromDTOToEntity());
|
||||
DbContext.SaveChangesAsync();
|
||||
return newInquiryEntity;
|
||||
}
|
||||
|
||||
public bool DeleteInquiry(int id)
|
||||
{
|
||||
var inquiryEntity = DbContext.Inquiries.FirstOrDefault(u => u.Id == id);
|
||||
if (inquiryEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DbContext.Inquiries.Remove(inquiryEntity);
|
||||
DbContext.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public InquiryDTO UpdateInquiry(int id, InquiryDTO inquiry)
|
||||
{
|
||||
var updatingInquiry = DbContext.Inquiries.FirstOrDefault(u => u.Id == id);
|
||||
if (updatingInquiry == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'enquête", nameof(id));
|
||||
}
|
||||
|
||||
updatingInquiry.Title = inquiry.Title;
|
||||
updatingInquiry.Description = inquiry.Description;
|
||||
updatingInquiry.IsUser = inquiry.IsUser;
|
||||
DbContext.SaveChangesAsync();
|
||||
return updatingInquiry.FromEntityToDTO();
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
using DbContextLib;
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Dto;
|
||||
using Model.OrderCriteria;
|
||||
using Shared.Mapper;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public class LessonDataService : ILessonDataService
|
||||
{
|
||||
private UserDbContext DbContext { get; set; }
|
||||
public LessonDataService(UserDbContext context)
|
||||
{
|
||||
DbContext = context;
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
public IEnumerable<LessonDTO> GetLessons(int page, int number, LessonOrderCriteria orderCriteria)
|
||||
{
|
||||
IQueryable<LessonEntity> query = DbContext.Lessons.Skip((page - 1) * number).Take(number);
|
||||
switch (orderCriteria)
|
||||
{
|
||||
case LessonOrderCriteria.None:
|
||||
break;
|
||||
case LessonOrderCriteria.ByTitle:
|
||||
query = query.OrderBy(s => s.Title);
|
||||
break;
|
||||
case LessonOrderCriteria.ByLastPublisher:
|
||||
query = query.OrderBy(s => s.LastPublisher);
|
||||
break;
|
||||
case LessonOrderCriteria.ByLastEdit:
|
||||
query = query.OrderBy(s => s.LastEdit);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var lessons = query.ToList();
|
||||
return lessons.Select(s => s.FromEntityToDTO());
|
||||
}
|
||||
|
||||
public LessonDTO GetLessonById(int id)
|
||||
{
|
||||
var lessonEntity = DbContext.Lessons.FirstOrDefault(u => u.Id == id);
|
||||
if (lessonEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver la leçon", nameof(id));
|
||||
}
|
||||
|
||||
return lessonEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public LessonDTO GetLessonByTitle(string title)
|
||||
{
|
||||
var lessonEntity = DbContext.Lessons.FirstOrDefault(u => u.Title == title);
|
||||
if (lessonEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver la leçon", nameof(title));
|
||||
}
|
||||
|
||||
return lessonEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public bool DeleteLesson(int id)
|
||||
{
|
||||
var lessonEntity = DbContext.Lessons.FirstOrDefault(l => l.Id == id);
|
||||
if (lessonEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DbContext.Lessons.Remove(lessonEntity);
|
||||
DbContext.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public LessonDTO UpdateLesson(int id, LessonDTO lesson)
|
||||
{
|
||||
var updatingLesson = DbContext.Lessons.FirstOrDefault(l => l.Id == id);
|
||||
if (updatingLesson == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver la leçon", nameof(id));
|
||||
}
|
||||
|
||||
updatingLesson.Title = lesson.Title;
|
||||
updatingLesson.LastPublisher = lesson.LastPublisher;
|
||||
updatingLesson.LastEdit = lesson.LastEdit;
|
||||
DbContext.SaveChangesAsync();
|
||||
return updatingLesson.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public LessonDTO CreateLesson(string title, string lastPublisher, DateOnly? lastEdit)
|
||||
{
|
||||
var newLessonEntity = new LessonDTO()
|
||||
{
|
||||
Title = title,
|
||||
LastPublisher = lastPublisher,
|
||||
LastEdit = lastEdit,
|
||||
};
|
||||
DbContext.Lessons.Add(newLessonEntity.FromDTOToEntity());
|
||||
DbContext.SaveChangesAsync();
|
||||
return newLessonEntity;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Dto;
|
||||
using DbContextLib;
|
||||
using Model.OrderCriteria;
|
||||
using Shared;
|
||||
using Shared.Mapper;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public class ParagraphDataService : IParagraphDataService
|
||||
{
|
||||
private UserDbContext DbContext { get; set; }
|
||||
public ParagraphDataService(UserDbContext context)
|
||||
{
|
||||
DbContext = context;
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public IEnumerable<ParagraphDTO> GetParagraphs(int page, int number, ParagraphOrderCriteria orderCriteria)
|
||||
{
|
||||
IQueryable<ParagraphEntity> query = DbContext.Paragraphs.Skip((page - 1) * number).Take(number);
|
||||
switch (orderCriteria)
|
||||
{
|
||||
case ParagraphOrderCriteria.None:
|
||||
break;
|
||||
case ParagraphOrderCriteria.ByTitle:
|
||||
query = query.OrderBy(s => s.Title);
|
||||
break;
|
||||
case ParagraphOrderCriteria.ByContent:
|
||||
query = query.OrderBy(s => s.Content);
|
||||
break;
|
||||
case ParagraphOrderCriteria.ByInfo:
|
||||
query = query.OrderBy(s => s.Info);
|
||||
break;
|
||||
case ParagraphOrderCriteria.ByQuery:
|
||||
query = query.OrderBy(s => s.Query);
|
||||
break;
|
||||
case ParagraphOrderCriteria.ByComment:
|
||||
query = query.OrderBy(s => s.Comment);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var paragraphs = query.ToList();
|
||||
return paragraphs.Select(s => s.FromEntityToDTO());
|
||||
}
|
||||
|
||||
public ParagraphDTO GetParagraphById(int id)
|
||||
{
|
||||
var paragraphEntity = DbContext.Paragraphs.FirstOrDefault(u => u.Id == id);
|
||||
if (paragraphEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le paragraphe", nameof(id));
|
||||
}
|
||||
|
||||
return paragraphEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public ParagraphDTO GetParagraphByTitle(string title)
|
||||
{
|
||||
var paragraphEntity = DbContext.Paragraphs.FirstOrDefault(u => u.Title == title);
|
||||
if (paragraphEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le paragraphe", nameof(title));
|
||||
}
|
||||
|
||||
return paragraphEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public bool DeleteParagraph(int id)
|
||||
{
|
||||
var paragraphEntity = DbContext.Paragraphs.FirstOrDefault(p => p.Id == id);
|
||||
if (paragraphEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DbContext.Paragraphs.Remove(paragraphEntity);
|
||||
DbContext.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public ParagraphDTO UpdateParagraph(int id, ParagraphDTO paragraphDTO)
|
||||
{
|
||||
var updatingParagraph = DbContext.Paragraphs.FirstOrDefault(p => p.Id == id);
|
||||
if (updatingParagraph == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le paragraphe", nameof(id));
|
||||
}
|
||||
|
||||
updatingParagraph.Title = paragraphDTO.Title;
|
||||
updatingParagraph.Content = paragraphDTO.Content;
|
||||
updatingParagraph.Info = paragraphDTO.Info;
|
||||
updatingParagraph.Query = paragraphDTO.Query;
|
||||
updatingParagraph.Comment = paragraphDTO.Comment;
|
||||
DbContext.SaveChangesAsync();
|
||||
return updatingParagraph.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public ParagraphDTO CreateParagraph(string title, string content, string info, string query, string comment, int lessonId)
|
||||
{
|
||||
var newParagraphEntity = new ParagraphDTO()
|
||||
{
|
||||
Title = title,
|
||||
Content = content,
|
||||
Info = info,
|
||||
Query = query,
|
||||
Comment = comment,
|
||||
LessonId = lessonId
|
||||
};
|
||||
DbContext.Paragraphs.Add(newParagraphEntity.FromDTOToEntity());
|
||||
DbContext.SaveChangesAsync();
|
||||
return newParagraphEntity;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
using Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Dto;
|
||||
using DbContextLib;
|
||||
using Model.OrderCriteria;
|
||||
using Shared.Mapper;
|
||||
|
||||
namespace Shared;
|
||||
|
||||
public class SuccessDataService : ISuccessDataService
|
||||
{
|
||||
private UserDbContext DbContext { get; set; }
|
||||
public SuccessDataService(UserDbContext context)
|
||||
{
|
||||
DbContext = context;
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
public IEnumerable<SuccessDTO> GetSuccesses(int page, int number, SuccessOrderCriteria orderCriteria)
|
||||
{
|
||||
IQueryable<SuccessEntity> query = DbContext.Successes.Skip((page - 1) * number).Take(number);
|
||||
switch (orderCriteria)
|
||||
{
|
||||
case SuccessOrderCriteria.None:
|
||||
break;
|
||||
case SuccessOrderCriteria.ByUserId:
|
||||
query = query.OrderBy(s => s.UserId);
|
||||
break;
|
||||
case SuccessOrderCriteria.ByInquiryId:
|
||||
query = query.OrderBy(s => s.InquiryId);
|
||||
break;
|
||||
case SuccessOrderCriteria.ByIsFinished:
|
||||
query = query.OrderBy(s => s.IsFinished);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var successes = query.ToList();
|
||||
return successes.Select(s => s.FromEntityToDTO());
|
||||
}
|
||||
|
||||
public SuccessDTO GetSuccessByUserId(int id)
|
||||
{
|
||||
var userEntity = DbContext.Successes.FirstOrDefault(u => u.UserId == id);
|
||||
if (userEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le succès", nameof(id));
|
||||
}
|
||||
|
||||
return userEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public SuccessDTO GetSuccessByInquiryId(int id)
|
||||
{
|
||||
var userEntity = DbContext.Successes.FirstOrDefault(u => u.InquiryId == id);
|
||||
if (userEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le succès", nameof(id));
|
||||
}
|
||||
|
||||
return userEntity.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public bool DeleteSuccess(int id)
|
||||
{
|
||||
var successEntity = DbContext.Successes.FirstOrDefault(u => u.UserId == id);
|
||||
if (successEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DbContext.Successes.Remove(successEntity);
|
||||
DbContext.SaveChangesAsync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public SuccessDTO UpdateSuccess(int id, SuccessDTO success)
|
||||
{
|
||||
var updatingSuccess = DbContext.Successes.FirstOrDefault(u => u.UserId == id);
|
||||
if (updatingSuccess == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver le succès", nameof(id));
|
||||
}
|
||||
|
||||
updatingSuccess.UserId = success.UserId;
|
||||
updatingSuccess.InquiryId = success.InquiryId;
|
||||
updatingSuccess.IsFinished = success.IsFinished;
|
||||
DbContext.SaveChangesAsync();
|
||||
return updatingSuccess.FromEntityToDTO();
|
||||
}
|
||||
|
||||
public SuccessDTO CreateSuccess(int userId, int inquiryId, bool isFinished)
|
||||
{
|
||||
var newSuccessEntity = new SuccessDTO()
|
||||
{
|
||||
UserId = userId,
|
||||
InquiryId = inquiryId,
|
||||
IsFinished = isFinished,
|
||||
};
|
||||
DbContext.Successes.Add(newSuccessEntity.FromDTOToEntity());
|
||||
DbContext.SaveChangesAsync();
|
||||
return newSuccessEntity;
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
using Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Entities;
|
||||
using Shared.Mapper;
|
||||
using DbContextLib;
|
||||
using Model.OrderCriteria;
|
||||
|
||||
namespace Shared
|
||||
{
|
||||
public class UserDataService : IUserDataService
|
||||
{
|
||||
private UserDbContext DbContext { get; set; }
|
||||
|
||||
public UserDataService(UserDbContext context)
|
||||
{
|
||||
DbContext = context;
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public UserDTO GetUserById(int id)
|
||||
{
|
||||
var userEntity = DbContext.Users.FirstOrDefault(u => u.Id == id);
|
||||
if (userEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'utilisateur", nameof(id));
|
||||
}
|
||||
|
||||
return userEntity.FromEntityToDTO();
|
||||
|
||||
}
|
||||
|
||||
public UserDTO GetUserByUsername(string username)
|
||||
{
|
||||
var userEntity = DbContext.Users.FirstOrDefault(u => u.Username == username);
|
||||
if (userEntity == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'utilisateur", nameof(username));
|
||||
}
|
||||
|
||||
return userEntity.FromEntityToDTO();
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<UserDTO> GetUsers(int page, int number, UserOrderCriteria orderCriteria)
|
||||
{
|
||||
IQueryable<UserEntity> query = DbContext.Users.Skip((page - 1) * number).Take(number);
|
||||
switch (orderCriteria)
|
||||
{
|
||||
case UserOrderCriteria.None:
|
||||
break;
|
||||
case UserOrderCriteria.ById:
|
||||
query = query.OrderBy(s => s.Id);
|
||||
break;
|
||||
case UserOrderCriteria.ByUsername:
|
||||
query = query.OrderBy(s => s.Username);
|
||||
break;
|
||||
case UserOrderCriteria.ByEmail:
|
||||
query = query.OrderBy(s => s.Email);
|
||||
break;
|
||||
case UserOrderCriteria.ByIsAdmin:
|
||||
query = query.OrderBy(s => s.IsAdmin);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var users = query.ToList();
|
||||
return users.Select(s => s.FromEntityToDTO());
|
||||
}
|
||||
|
||||
public bool DeleteUser(int id)
|
||||
{
|
||||
var userEntity = DbContext.Users.FirstOrDefault(u => u.Id == id);
|
||||
if (userEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DbContext.Users.Remove(userEntity);
|
||||
DbContext.SaveChangesAsync();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public UserDTO UpdateUser(int id, UserDTO user)
|
||||
{
|
||||
var updatingUser = DbContext.Users.FirstOrDefault(u => u.Id == id);
|
||||
if (updatingUser == null)
|
||||
{
|
||||
throw new ArgumentException("Impossible de trouver l'utilisateur", nameof(id));
|
||||
}
|
||||
|
||||
updatingUser.Username = user.Username;
|
||||
updatingUser.Password = user.Password;
|
||||
updatingUser.Email = user.Email;
|
||||
updatingUser.IsAdmin = user.IsAdmin;
|
||||
DbContext.SaveChangesAsync();
|
||||
return updatingUser.FromEntityToDTO();
|
||||
|
||||
}
|
||||
|
||||
public UserDTO CreateUser(string username, string password, string email, bool isAdmin)
|
||||
{
|
||||
var newUserEntity = new UserDTO
|
||||
{
|
||||
Username = username,
|
||||
Password = password,
|
||||
Email = email,
|
||||
IsAdmin = isAdmin
|
||||
};
|
||||
DbContext.Users.Add(newUserEntity.FromDTOToEntity());
|
||||
DbContext.SaveChangesAsync();
|
||||
return newUserEntity;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue