public ActionResult Edit(Models.Seance.AddViewModel model) { if (!ModelState.IsValid) { //select lists return(View(model)); } var apiResponseModel = _seanceService.GetById(SessionHelper.CurrentUser.UserToken, model.Id); if (apiResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success) { //select lists ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; return(View(model)); } var seance = apiResponseModel.Data; if (seance == null) { return(View("_ErrorNotExist")); } seance.Name = model.Name; seance.Date = model.Date; seance.Time = model.Time; var apiEditResponseModel = _seanceService.Edit(SessionHelper.CurrentUser.UserToken, seance); if (apiEditResponseModel.ResultStatusCode != ResultStatusCodeStatic.Success) { ViewBag.ErrorMessage = apiEditResponseModel.ResultStatusMessage != null ? apiEditResponseModel.ResultStatusMessage : "Not Edited"; // select lists return(View(model)); } return(RedirectToAction(nameof(SeanceController.List))); }
public ActionResult Add(Models.Seance.AddViewModel model) { if (!ModelState.IsValid) { //select lists return(View(model)); } Business.Models.Seance.Seance seance = new Business.Models.Seance.Seance(); seance.Name = model.Name; seance.Date = model.Date; seance.Time = model.Time; var apiResponseModel = _seanceService.Add(SessionHelper.CurrentUser.UserToken, seance); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { return(RedirectToAction(nameof(SeanceController.List))); } else { ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage != null ? apiResponseModel.ResultStatusMessage : "Not Saved"; return(View(model)); } }