public ActionResult Create(RightBannerViewModel item) { if (ModelState.IsValid) { RightBanner model = new RightBanner(); model.Name = item.Name; model.PlanName = item.PlanName; model.Unit = item.Unit; model.Link = item.Link; if (_iServiceRighBanner.SaveAdd(model)) { SessionUserHelper.CreateSessionSuccess(ConstantStrings.AddSuccess); } else { SessionUserHelper.CreateSessionError(ConstantStrings.AddNonSuccess); } return RedirectToAction("Index"); } return View(item); }
public RightBanner GetRightBannerModel(RightBannerViewModel model) { var item = new RightBanner(); item.Id = model.Id; item.Name = model.Name; item.Unit = model.Unit; item.PlanName = model.PlanName; item.Link = model.Link; return item; }
public ActionResult UpdateSTT(int ID, string STT) { try { if (ModelState.IsValid) { if (Int32.Parse(STT) <= 0) { SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess); return RedirectToAction("Index"); } var model = new RightBanner(); model.Id = ID; model.STT = Int32.Parse(STT); if (_iServiceRighBanner.UpdateSTT(model)) { SessionUserHelper.CreateSessionSuccess(ConstantStrings.EditSuccess); } else { SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess); } return RedirectToAction("Index"); } SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess); return RedirectToAction("Index"); } catch (Exception) { SessionUserHelper.CreateSessionError(ConstantStrings.EditNonSuccess); return RedirectToAction("Index"); } }
public bool UpdateSTT(RightBanner item) { try { using (_context = new GreenhouseBannerContext()) { RightBanner bannerRight = _context.RightBanners.FirstOrDefault(c => c.Id == item.Id); if (bannerRight != null) { var account = System.Web.HttpContext.Current.Session["Account"] as Account; bannerRight.UserModifyId = account.UserId; bannerRight.STT = item.STT; bannerRight.ModifyDate = DateTime.Now; _context.SaveChanges(); return true; } return false; } } catch (Exception ex) { return false; } }