public UserClassGetDto EditUserClass(int Id, UserClassEditDto userClassEditDto) { var userClass = _context.Set <UserClass>().Find(Id); userClass.Grade = userClassEditDto.Grade; userClass.ClassCompleted = userClassEditDto.ClassCompleted; userClass.UserId = userClassEditDto.UserId; userClass.UserId = userClassEditDto.UserId; _context.SaveChanges(); var userClassGetDto = new UserClassGetDto { Id = userClass.Id, Grade = userClass.Grade, ClassCompleted = userClass.ClassCompleted, UserId = userClass.UserId, ClassId = userClass.ClassId }; userClassGetDto.Id = userClass.Id; return(userClassGetDto); }
public UserClassGetDto CreateUserClass(UserClassCreateDto userClassCreateDto) { var userClass = new UserClass { Grade = userClassCreateDto.Grade, ClassCompleted = userClassCreateDto.ClassCompleted, UserId = userClassCreateDto.UserId, ClassId = userClassCreateDto.ClassId }; _context.Set <UserClass>().Add(userClass); _context.SaveChanges(); var userClassGetDto = new UserClassGetDto { Id = userClass.Id, Grade = userClass.Grade, ClassCompleted = userClass.ClassCompleted, UserId = userClass.UserId, ClassId = userClass.ClassId }; return(userClassGetDto); }