Example #1
0
        public ActionResult SaveItem(DocumentsType model)
        {
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int                IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DocumentsTypeModel data           = new DocumentsTypeModel()
            {
                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"]);
                    DocumentsTypeService.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));
        }
Example #2
0
        public IActionResult Index([FromQuery] SearchDocumentsType dto)
        {
            int                TotalItems     = 0;
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DocumentsTypeModel data           = new DocumentsTypeModel()
            {
                SearchData = dto
            };

            data.ListItems = DocumentsTypeService.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));
        }
Example #3
0
        public IActionResult SaveItem(string Id = null)
        {
            DocumentsTypeModel data           = new DocumentsTypeModel();
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

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


            return(View(data));
        }