public void Create(CreateSessionDto dto) { var session = _mapper.Map <SessionDbEntity>(dto); _DB.Sessions.Add(session); _DB.SaveChanges(); }
public void Create(CreateStudentDto dto) { var student = (StudentDbEntity)_mapper.Map <StudentDbEntity>(dto); _DB.Students.Add(student); _sessionService.UpdateStudentsCount(dto.SessionId, increase: true); _DB.SaveChanges(); }
public async Task Create(CreateMCQuestionDto dto) { var mcq = _mapper.Map <MCQuestionDbEntity>(dto); if (dto.AttachmentURL != null) { mcq.AttachmentURL = await _fileService.SaveFile(dto.AttachmentURL, "Attachments"); await _DB.MCQustions.AddAsync(mcq); } else { _DB.MCQustions.Add(mcq); } _DB.SaveChanges(); }
public void Create(CreateQuizDto dto) { var quiz = _mapper.Map <QuizDbEntity>(dto); _DB.Quizzes.Add(quiz); _DB.SaveChanges(); }
public async Task <LoginResponseViewModel> LoginAsync(LoginDto dto) { var user = _DB.Users.SingleOrDefault(x => x.UserName == dto.Username && !x.IsDelete); if (user == null) { throw new InvalidUsernameException(); } var result = await _signInManager.CheckPasswordSignInAsync(user, dto.Password, false); if (result.Succeeded) { // We can check here if the user is active //user.FCMToken = dto.FCM; _DB.Users.Update(user); _DB.SaveChanges(); var token = await GenerateAccessToken(user); var response = new LoginResponseViewModel(); response.Token = token; response.User = _Mapper.Map <UserViewModel>(user); //response.User = new UserViewModel() //{ // Id = user.Id, // Name = user.Name, // Email = user.Email, // PhoneNumber = user.PhoneNumber, // UpdatedAt = user.UpdatedAt, // FCMToken = user.FCMToken //}; //var uservm = _Mapper.Map<UserViewModel>(user); return(response); } throw new InvalidUsernameException(); }