public ActionResult Create() { EditVM model = new EditVM(); model.NationalitiesList = LoadDataUtil.LoadNationalitiesData(); model.FacultiesList = LoadDataUtil.LoadFacultiesData(); return(View(model)); }
public ActionResult Edit(int id) { using (_service.Service) { SR.MVCWebSite.StudentsService.StudentDTO item = _service.Service.GetStudents().Where(x => x.Id == id).FirstOrDefault(); EditVM model = new EditVM(); model.PopulateModel(item); model.NationalitiesList = LoadDataUtil.LoadNationalitiesData(); model.FacultiesList = LoadDataUtil.LoadFacultiesData(); return(View(model)); } }
public ActionResult Create(EditVM model) { try { if (ModelState.IsValid) { using (_service.Service) { SR.MVCWebSite.StudentsService.StudentDTO item = new SR.MVCWebSite.StudentsService.StudentDTO(); model.PopulateEntityDTO(item); _service.Service.PostStudent(item); } return(RedirectToAction("Index")); } model.NationalitiesList = LoadDataUtil.LoadNationalitiesData(); model.FacultiesList = LoadDataUtil.LoadFacultiesData(); return(View(model)); } catch { return(View(model)); } }