public ActionResult SaveItem(DMLoaiCoQuan model)
        {
            string            ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int               IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DMLoaiCoQuanModel data           = new DMLoaiCoQuanModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    DMLoaiCoQuanService.SaveItem(model);
                    if (model.Id > 0)
                    {
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                    }
                    else
                    {
                        TempData["MessageSuccess"] = "Thêm mới thành công";
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(data));
        }
        public IActionResult Index([FromQuery] SearchDMLoaiCoQuan dto)
        {
            int               TotalItems     = 0;
            string            ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DMLoaiCoQuanModel data           = new DMLoaiCoQuanModel()
            {
                SearchData = dto
            };

            data.ListItems = DMLoaiCoQuanService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };

            return(View(data));
        }
        public IActionResult SaveItem(string Id = null)
        {
            DMLoaiCoQuanModel data           = new DMLoaiCoQuanModel();
            string            ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDMLoaiCoQuan()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new DMLoaiCoQuan();
            }
            else
            {
                data.Item = DMLoaiCoQuanService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }