public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); DMCoQuan item = new DMCoQuan() { Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status }; try { if (item.Id > 0) { item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); dynamic UpdateStatus = DMCoQuanService.UpdateStatus(item); TempData["MessageSuccess"] = "Cập nhật Trạng Thái thành công"; return(Json(new MsgSuccess())); } else { TempData["MessageError"] = "Cập nhật Trạng Thái Không thành công"; return(Json(new MsgError())); } } catch { TempData["MessageSuccess"] = "Cập nhật Trạng Thái không thành công"; return(Json(new MsgError())); } }
public ActionResult DeleteItem(string Id) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); DMCoQuanModel data = new DMCoQuanModel(); DMCoQuan item = new DMCoQuan() { Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString()) }; try { if (item.Id > 0) { item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); DMCoQuanService.DeleteItem(item); TempData["MessageSuccess"] = "Xóa thành công"; return(Json(new MsgSuccess())); } else { TempData["MessageError"] = "Xóa Không thành công"; return(Json(new MsgError())); } } catch { TempData["MessageSuccess"] = "Xóa không thành công"; return(Json(new MsgError())); } }
public IActionResult Index(string alias) { DMCoQuan item = DMCoQuanService.GetItemByCode(alias); DMCoQuanModel data = new DMCoQuanModel() { Item = item }; HttpContext.Session.SetString("IdLayoutSite", item.IdLayout.ToString()); HttpContext.Session.SetString("IdCoQuan", item.Id.ToString()); HttpContext.Session.SetString("Title_1", item.Title_1); HttpContext.Session.SetString("Title_2", item.Title_2); HttpContext.Session.SetString("Title_3", item.Title_3); return(View(data)); }
public ActionResult SaveItem(DMCoQuan model) { string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); int IdDC = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString()); DMCoQuanModel data = new DMCoQuanModel(); data.ListItemsLayout = DMCoQuanService.GetListLayout(); data.ListItemsLoaiCoQuan = DMLoaiCoQuanService.GetListSelectItems(); data.Item = model; if (ModelState.IsValid) { if (model.Id == IdDC) { model.CreatedBy = model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]); var Obj = DMCoQuanService.SaveItem(model); if (Obj.N == -1) { TempData["MessageError"] = "Mã cơ quan trùng"; data.ListItemsCoQuan = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId); return(View(data)); } else if (Obj.N == -2) { TempData["MessageError"] = "Chọn Cơ quan cha không hợp lệ"; data.ListItemsCoQuan = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId); return(View(data)); } else { TempData["MessageSuccess"] = "Cập nhật thành công"; return(RedirectToAction("Index", new { CategoryId = model.CategoryId })); } } } else { data.ListItemsCoQuan = DMCoQuanService.GetListByLoaiCoQuan(model.CategoryId); } return(View(data)); }