public async Task <bool> SetDateStudy(string email, DateTime date) { ApplicationUser user = await database.UserManager.FindByEmailAsync(email); if (user != null) { BeginStudy beginStudy = await database.StudyRepository.FindByDate(date); if (beginStudy == null) { throw new ValidationException("Not found this date:", date.ToString()); } try { await database.StudentRepository.SetStudyDate(email, beginStudy); await database.SaveAsync(); } catch (DbUpdateException) { throw new ValidationException("Not success set StudyDate", date.ToString()); } return(true); } else { throw new ValidationException("Not found this email:", email); } }
public async Task SetStudyDate(string email, BeginStudy date) { Student student = await GetByEmailAsync(email); student.BeginStudy = date; Database.Entry(student).State = EntityState.Modified; }
public async Task <BeginStudyDTO> FindDateById(int id) { BeginStudy beginStudy = await database.StudyRepository.FindById(id); return(new BeginStudyDTO { Id = beginStudy.Id, Date = beginStudy.DateStudy }); }