public IActionResult Modify(PointLimit model) { if (!_loginServices.isInAdminRoles(this.GetRoles())) { return(RedirectToAction("Login", "Accounts")); } if (ModelState.IsValid) { if (model.ID <= 0) { model.Create_On = DateUtil.Now(); model.Create_By = this.HttpContext.User.Identity.Name; model.Update_On = DateUtil.Now(); model.Update_By = this.HttpContext.User.Identity.Name; this._context.PointLimits.Add(model); this._context.SaveChanges(); return(RedirectToAction("Index")); } else { model.Update_On = DateUtil.Now(); model.Update_By = this.HttpContext.User.Identity.Name; this._context.Update(model); this._context.SaveChanges(); return(RedirectToAction("Index")); } } else { ModelState.AddModelError("Error", "มีข้อผิดพลาดไม่สามารถบันทึกข้อมูล"); } return(View("LimitInfo", model)); }
public IActionResult Index() { if (!_loginServices.isInAdminRoles(this.GetRoles())) { return(RedirectToAction("Login", "Accounts")); } var model = this._context.PointLimits.FirstOrDefault(); if (model == null) { model = new PointLimit(); } return(View("LimitInfo", model)); }