Exemple #1
0
        public IActionResult Index([FromQuery] SearchDocuments dto)
        {
            int            TotalItems     = 0;
            string         ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            DocumentsModel data           = new DocumentsModel()
            {
                SearchData = dto
            };

            data.SearchData.Status = 0;
            data.ListItems         = DocumentsService.GetListPagination(data.SearchData, API.Models.Settings.SecretId + ControllerName);
            if (data.ListItems != null && data.ListItems.Count() > 0)
            {
                TotalItems = data.ListItems[0].TotalRows;
            }
            data.Pagination = new Areas.Admin.Models.Partial.PartialPagination()
            {
                CurrentPage = data.SearchData.CurrentPage, ItemsPerPage = data.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString()
            };
            data.ListDocumentsCategories = DocumentsCategoriesService.GetListSelectItems();
            data.ListDocumentsType       = DocumentsTypeService.GetListSelectItems();
            data.ListDocumentsField      = DocumentsFieldService.GetListSelectItems();
            data.ListDocumentsLevel      = DocumentsLevelService.GetListSelectItems();
            return(View(data));
        }
Exemple #2
0
        public IActionResult SaveItem(string Id = null)
        {
            DocumentsModel data           = new DocumentsModel();
            string         ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int            IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDocuments()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListDocumentsCategories = DocumentsCategoriesService.GetListSelectItems();
            data.ListDocumentsType       = DocumentsTypeService.GetListSelectItems();
            data.ListDocumentsField      = DocumentsFieldService.GetListSelectItems();
            data.ListDocumentsLevel      = DocumentsLevelService.GetListSelectItems();
            Documents Item = new Documents()
            {
                IssuedDateShow    = DateTime.Now.ToString("dd/MM/yyyy"),
                EffectiveDateShow = DateTime.Now.ToString("dd/MM/yyyy")
            };

            if (IdDC > 0)
            {
                Item = DocumentsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }

            data.Item = Item;

            return(View(data));
        }
Exemple #3
0
        public ActionResult SaveItem(Documents model)
        {
            string         ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int            IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            DocumentsModel data           = new DocumentsModel()
            {
                Item = model
            };

            data.ListDocumentsCategories = DocumentsCategoriesService.GetListSelectItems();
            data.ListDocumentsType       = DocumentsTypeService.GetListSelectItems();
            data.ListDocumentsField      = DocumentsFieldService.GetListSelectItems();
            data.ListDocumentsLevel      = DocumentsLevelService.GetListSelectItems();
            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    try
                    {
                        DocumentsService.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"));
                    }
                    catch
                    {
                        TempData["MessageError"] = "Lỗi khi lưu dữ liệu";
                    }
                }
            }
            return(View(data));
        }