public ActionResult Create(BannerManageModel model, SubmitTypeEnums submit) { if (ModelState.IsValid) { var response = _bannerServices.SaveBanner(model); if (response.Success) { var templateId = (int)response.Data; SetSuccessMessage(response.Message); switch (submit) { case SubmitTypeEnums.Save: return RedirectToAction("Index"); default: return RedirectToAction("Edit", new { id = templateId }); } } SetErrorMessage(response.Message); } return View(model); }
/// <summary> /// Save banner /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel SaveBanner(BannerManageModel model) { ResponseModel response; var banner = GetById(model.Id); if (banner != null) { banner.ImageUrl = model.ImageUrl; banner.Text = model.Text; banner.Url = model.Url; banner.GroupName = model.GroupName; banner.RecordOrder = model.RecordOrder; response = Update(banner); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::Banners:::Messages:::UpdateSuccessfully:::Update banner successfully.") : _localizedResourceServices.T("AdminModule:::Banners:::Messages:::UpdateFailure:::Update banner failed. Please try again later.")); } Mapper.CreateMap<BannerManageModel, Banner>(); banner = Mapper.Map<BannerManageModel, Banner>(model); response = Insert(banner); return response.SetMessage(response.Success ? _localizedResourceServices.T("AdminModule:::Banners:::Messages:::CreateSuccessfully:::Create banner successfully.") : _localizedResourceServices.T("AdminModule:::Banners:::Messages:::CreateFailure:::Create banner failed. Please try again later.")); }