public static EducationViewModel CreateViewModel(Education edu) { var model = new EducationViewModel(); model.Institution = edu.Institution; model.Specialty = edu.Specialty; model.StartDate = edu.StartDate; model.EndDate = edu.EndDate; model.Description = edu.Description; return model; }
// TODO: maybe delete or implement public ActionResult CreateConnection([DataSourceRequest] DataSourceRequest dsRequest, ProfileConnectionViewModel eduViewModel, int userId) { if (ModelState.IsValid) { var edu = new Education(); var user = db.UserProfiles.Find(userId); edu.UserId = user.UserId; edu.UserProfile = user; db.Education.Add(edu); db.SaveChanges(); } return Json(ModelState.ToDataSourceResult()); }
public ActionResult CreateEducation([DataSourceRequest] DataSourceRequest dsRequest, EducationViewModel eduViewModel, int userId) { if (ModelState.IsValid) { var edu = new Education(); var user = db.UserProfiles.Find(userId); edu.UserId = user.UserId; edu.UserProfile = user; edu.Institution = eduViewModel.Institution; edu.Specialty = eduViewModel.Specialty; edu.Description = eduViewModel.Description; edu.StartDate = eduViewModel.StartDate; edu.EndDate = eduViewModel.EndDate; db.Education.Add(edu); db.SaveChanges(); } return Json(ModelState.ToDataSourceResult()); }