Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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.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 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();
            data.ListItemsStatus         = DocumentsService.GetListItemsStatus();
            return(View(data));
        }
Ejemplo n.º 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));
        }