public ActionResult Create() { var defaultDate = DateTime.Today.Date; var viewModel = new AbsencePeriodViewModel { AbsencePeriod = new AbsencePeriod { StartDate = defaultDate, EndDate = defaultDate.AddYears(1).AddDays(-1), OrganisationId = UserOrganisationId } }; return(View(viewModel)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var absencePeriod = HRBusinessService.RetrieveAbsencePeriod(UserOrganisationId, id.Value); if (absencePeriod == null) { return(HttpNotFound()); } var viewModel = new AbsencePeriodViewModel { AbsencePeriod = absencePeriod }; return(View(viewModel)); }
public ActionResult Edit([Bind(Include = "AbsencePeriodId,StartDate,EndDate")] AbsencePeriod absencePeriod) { if (ModelState.IsValid) { var result = HRBusinessService.UpdateAbsencePeriod(UserOrganisationId, absencePeriod); if (result.Succeeded) { return(RedirectToAction("Index")); } foreach (var error in result.Errors) { ModelState.AddModelError("", error); } } var viewModel = new AbsencePeriodViewModel { AbsencePeriod = absencePeriod }; return(View(viewModel)); }