public ActionResult CreateOrUpdate([FromRoute] int systemUserId, [FromBody] IEnumerable <InformalExperienceModel> model) { var informalExperience = new UserInformalExperienceModel() { InformalExperiences = model, SystemUserId = systemUserId }; _informalExperienceService.CreateOrUpdate(informalExperience); return(Ok(MessageHelper.Success("The informal experiences have been updated."))); }
public void CreateOrUpdate(UserInformalExperienceModel model) { var informalExperiences = _informalExperienceRepository .GetPagedList(predicate: a => a.SystemUserId == model.SystemUserId, pageSize: int.MaxValue); if (informalExperiences.TotalCount > 0) { _informalExperienceRepository.Delete(informalExperiences.Items); } foreach (var informalExperience in model.InformalExperiences) { _informalExperienceRepository.Insert(new EduInformalExperience() { ExperienceId = informalExperience.Id, OtherExperience = informalExperience.OtherValue, SystemUserId = model.SystemUserId }); } _unitOfWork.SaveChanges(); }