public void Edit(EditedUserEducationModel model) { var education = _educationRepository.GetFirstOrDefault(predicate: a => a.EducationId == model.Id); if (education == null) { throw new ApplicationException("The Education Id is invalid"); } if (model.IsCurrentEducation) { UpdateOldCurrentEducation(model.SystemUserId, education.EducationId); } education.School = model.School; education.Degree = model.Degree; education.SystemUserId = model.SystemUserId; education.DateAttendedEnd = model.DateAttendedEnd.FromUnixTime(); education.DateAttendedStart = model.DateAttendedStart.FromUnixTime(); education.IsEduCurrentEducation = model.IsCurrentEducation; education.Grade = model.ModeOfStudy.ToString(); _educationRepository.Update(education); _unitOfWork.SaveChanges(); }
public ActionResult Edit([FromRoute] int systemUserId, [FromBody] EditedEducationViewModel model) { var education = new EditedUserEducationModel() { DateAttendedEnd = model.DateAttendedEnd, DateAttendedStart = model.DateAttendedStart, Degree = model.Degree, Id = model.Id, IsCurrentEducation = model.IsCurrentEducation, ModeOfStudy = model.ModeOfStudy, School = model.School, SystemUserId = systemUserId }; _educationService.Edit(education); return(Ok(MessageHelper.Success("The education has been updated."))); }