Пример #1
0
        public IActionResult SaveItem(string Id = null, int Type = 0)
        {
            ContactsModel data           = new ContactsModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchContacts()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new Contacts()
                {
                    CreatedDateShow = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), Type = Type
                };
            }
            else
            {
                data.Item = ContactsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #2
0
        public ActionResult UpdateStatus([FromQuery] string Ids, Boolean Status)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Ablums item           = new Ablums()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Status = Status
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateStatus = AblumsService.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()));
            }
        }
Пример #3
0
        public ActionResult SaveItem(Contacts model)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            ContactsModel data           = new ContactsModel()
            {
                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"]);
                    model.CreatedDate = DateTime.ParseExact(model.CreatedDateShow, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
                    ContactsService.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", new { @Type = model.Type, @EventId = model.EventId }));
                }
            }
            return(View(data));
        }
Пример #4
0
        public IActionResult SaveItem(string Id = null)
        {
            DMChucVuModel data           = new DMChucVuModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDMChucVu()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };

            /*
             * if (HttpContext.Session.GetString(ControllerName + "_Search")!= null)
             * {
             *  data.SearchData = JsonConvert.DeserializeObject<SearchDMChucVu>(HttpContext.Session.GetString(ControllerName + "_Search"));
             * }*/
            if (IdDC == 0)
            {
                data.Item = new DMChucVu();
            }
            else
            {
                data.Item = DMChucVuService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #5
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));
        }
Пример #6
0
        public IActionResult SaveItem(string Id = null)
        {
            USUsersModel data           = new USUsersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchUSUsers()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsGroups = USGroupsService.GetListSelectItems();
            data.ListItemsStatus = USUsersService.GetStatusSelectItems();
            data.ListDMCoQuan    = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            if (IdDC == 0)
            {
                data.Item = new USUsers();
            }
            else
            {
                data.Item = USUsersService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #7
0
        public ActionResult DeleteItem(string Id)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Ablums model          = new Ablums()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (model.Id > 0)
                {
                    model.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    AblumsService.DeleteItem(model);
                    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()));
            }
        }
Пример #8
0
        public IActionResult SaveItem(string Id = null, int CatId = 0, int IdCoQuan = 1)
        {
            ReviewsModel data           = new ReviewsModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchReviews()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };

            if (IdDC == 0)
            {
                data.Item = new Reviews()
                {
                    ReviewDate = DateTime.Now, ReviewDateShow = DateTime.Now.ToString("dd/MM/yyyy"), DisplayOder = 1, Status = true
                };
            }
            else
            {
                data.Item = ReviewsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }
            data.ListStart = ReviewsService.GetListStart();
            return(View(data));
        }
Пример #9
0
        public IActionResult SaveItem(string Id = null, int CatId = 0, int IdCoQuan = 1)
        {
            ProductsOrderModel data           = new ProductsOrderModel();
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchProductsOrder()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };

            if (IdDC == 0)
            {
                data.Item = new ProductsOrder()
                {
                    CreatedDate = DateTime.Now, Status = 0
                };
            }
            else
            {
                data.Item = ProductsOrderService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
                SearchProductsOrderDetail dts = new SearchProductsOrderDetail()
                {
                    ProductOrderId = IdDC
                };
                data.ListDetail = ProductsOrderDetailService.GetListPagination(dts, "");
            }
            return(View(data));
        }
Пример #10
0
        public IActionResult SaveItem(string Id = null)
        {
            DuAnModel data           = new DuAnModel();
            string    ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int       IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchDuAn()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsStatus    = DuAnService.GetListItemsStatus();
            data.ListItemsLoai      = DuAnService.GetListItemLoai();
            data.ListItemsTrangThai = DuAnService.GetListItemTrangThai();
            DuAn Item = new DuAn()
            {
                ThoiGianBatDauShow  = DateTime.Now.ToString("dd/MM/yyyy"),
                ThoiGianKetThucShow = DateTime.Now.ToString("dd/MM/yyyy"),
                Status = true
            };

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

            data.Item = Item;

            return(View(data));
        }
Пример #11
0
        public ActionResult SaveItem(Banners model)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            BannersModel data           = new BannersModel()
            {
                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"]);
                    BannersService.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", new { CatId = model.CatId, IdCoQuan = model.IdCoQuan }));
                }
            }
            else
            {
                data.ListItemsCategories = BannersCategoriesService.GetListSelectItems();
                data.ListDMCoQuan        = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            }
            return(View(data));
        }
Пример #12
0
        public ActionResult UpdateFeatured([FromQuery] string Ids, Boolean Featured)
        {
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Videos item           = new Videos()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Featured = Featured
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateFeatured = VideosService.UpdateFeatured(item);
                    TempData["MessageSuccess"] = "Cập nhật Nổi Bật thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật Nổi Bật Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageError"] = "Cập nhật Nổi Bật không thành công";
                return(Json(new MsgError()));
            }
        }
Пример #13
0
        public IActionResult SaveItem(string Id = null)
        {
            ProductsCategoriesModel data = new ProductsCategoriesModel();
            string ControllerName        = this.ControllerContext.RouteData.Values["controller"].ToString();
            int    IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.ListItemsDanhMuc = ProductsCategoriesService.GetListItems();
            data.SearchData       = new SearchProductsCategories()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item = new ProductsCategories()
                {
                    Status = true
                };
            }
            else
            {
                data.Item = ProductsCategoriesService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #14
0
        public ActionResult UpdateNotification([FromQuery] string Ids, Boolean Notification)
        {
            string   ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            Articles item           = new Articles()
            {
                Id = Int32.Parse(MyModels.Decode(Ids, API.Models.Settings.SecretId + ControllerName).ToString()), Notification = Notification
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    dynamic UpdateFeatured = ArticlesService.UpdateNotification(item);
                    TempData["MessageSuccess"] = "Cập nhật thông báo thành công";
                    return(Json(new MsgSuccess()));
                }
                else
                {
                    TempData["MessageError"] = "Cập nhật thông báo Không thành công";
                    return(Json(new MsgError()));
                }
            }
            catch
            {
                TempData["MessageSuccess"] = "Cập nhật thông báo không thành công";
                return(Json(new MsgError()));
            }
        }
Пример #15
0
        public ActionResult SaveItem(MenusModel model)
        {
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int        IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            MenusModel data           = model;

            if (ModelState.IsValid)
            {
                if (model.Item.Id == IdDC)
                {
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    MenusService.SaveItem(model.Item);
                    if (model.Item.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", new { IdCoQuan = model.Item.IdCoQuan }));
                }
            }
            data.ListType = MenusService.GetListType();
            return(View(data));
        }
Пример #16
0
        public IActionResult SaveItem(string Id = null)
        {
            ArticlesModel data           = new ArticlesModel();
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int           IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchArticles()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            data.ListItemsDanhMuc = CategoriesArticlesService.GetListItems();
            data.ListItemsAuthors = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            data.ListItemType     = ArticlesService.GetListItemsType();
            Articles Item = new Articles()
            {
                PublishUp = DateTime.Now, PublishUpShow = DateTime.Now.ToString("dd/MM/yyyy"), Status = true
            };

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

            data.Item = Item;
            return(View(data));
        }
Пример #17
0
        public IActionResult SaveItem(string Id = null, int IdCoQuan = 1)
        {
            MenusModel data           = new MenusModel();
            string     ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchMenus()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", IdCoQuan = IdCoQuan
            };
            data.ListItemsArticle       = ArticlesService.GetListStaticArticle();
            data.ListType               = MenusService.GetListType();
            data.ListCategoriesArticles = CategoriesArticlesService.GetList();
            data.ListCategoriesProducts = ProductsCategoriesService.GetList();
            data.ListItemsMenus         = MenusService.GetListItems(true, IdCoQuan);

            if (IdDC == 0)
            {
                data.Item = new Menus();
            }
            else
            {
                data.Item = MenusService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #18
0
        public IActionResult SaveItem(string Id = null, int CatId = 0, int IdCoQuan = 1)
        {
            BannersModel data           = new BannersModel();
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.SearchData = new SearchBanners()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = "", CatId = CatId, IdCoQuan = IdCoQuan
            };
            data.ListItemsCategories = BannersCategoriesService.GetListSelectItems();
            data.ListDMCoQuan        = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
            if (IdDC == 0)
            {
                data.Item = new Banners()
                {
                    CatId = CatId, Status = true
                };
            }
            else
            {
                data.Item = BannersService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }


            return(View(data));
        }
Пример #19
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));
        }
Пример #20
0
        public IActionResult SaveItem(string Id = null, int CategoryId = 0, int ParentId = 0)
        {
            DMCoQuanModel data = new DMCoQuanModel();

            data.ListItemsCoQuan     = DMCoQuanService.GetListByLoaiCoQuan(CategoryId);
            data.ListItemsLayout     = DMCoQuanService.GetListLayout();
            data.ListItemsLoaiCoQuan = DMLoaiCoQuanService.GetListSelectItems();
            int    IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + "DMCoQuan").ToString());
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();

            data.SearchData = new SearchDMCoQuan()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            if (IdDC == 0)
            {
                data.Item            = new DMCoQuan();
                data.Item.CategoryId = CategoryId;
                data.Item.ParentId   = ParentId;
            }
            else
            {
                data.Item = DMCoQuanService.GetItem(IdDC, API.Models.Settings.SecretId + "DMCoQuan".ToString());
            }


            return(View(data));
        }
Пример #21
0
        public IActionResult SaveItem(string Id = null)
        {
            DMQuanHuyenModel data = new DMQuanHuyenModel();
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + "DMQuanHuyen").ToString());

            data.Item = DMQuanHuyenService.GetItem(IdDC, API.Models.Settings.SecretId + "DMQuanHuyen".ToString());
            return(View(data));
        }
Пример #22
0
        public async Task <ActionResult> SaveItem(Articles data)
        {
            ArticlesModel model = new ArticlesModel()
            {
                Item = data
            };
            string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int    IdDC           = Int32.Parse(MyModels.Decode(model.Item.Ids, API.Models.Settings.SecretId + ControllerName).ToString());

            if (ModelState.IsValid)
            {
                if (data.Alias == null || data.Alias == "")
                {
                    model.Item.Alias = API.Models.MyHelper.StringHelper.UrlFriendly(data.Title);
                }
                if (model.Item.Icon != null)
                {
                    var Image = await FileHelpers.ProcessFormFile(model.Item.Icon, ModelState);

                    if (Image.Length > 0)
                    {
                        model.Item.Images = Image;
                    }
                }
                if (model.Item.Id == IdDC)
                {
                    model.Item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.Item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    model.Item.IdCoQuan   = int.Parse(HttpContext.Request.Headers["IdCoQuan"]);
                    try
                    {
                        ArticlesService.SaveItem(model.Item);
                        TempData["MessageSuccess"] = "Cập nhật thành công";
                        string Str_Url = HttpContext.Session.GetString("STR_Action_Link_" + ControllerName);
                        if (Str_Url != null && Str_Url != "")
                        {
                            return(Redirect("/Admin/" + this.ControllerContext.RouteData.Values["controller"].ToString() + "/Index" + Str_Url));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch
                    {
                    }
                }
            }
            model.SearchData = new SearchArticles()
            {
                CurrentPage = 0, ItemsPerPage = 10, Keyword = ""
            };
            model.ListItemsDanhMuc = CategoriesArticlesService.GetListItems();
            model.ListItemsAuthors = API.Areas.Admin.Models.USUsers.USUsersService.GetListItemsAuthor(4);
            model.ListItemType     = ArticlesService.GetListItemsType();
            return(View(model));
        }
Пример #23
0
        public IActionResult ViewLog(string Id = null)
        {
            string        ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            ArticlesModel data           = new ArticlesModel()
            {
            };
            int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            data.ListItems = ArticlesService.GetListLogArticles(IdDC, API.Models.Settings.SecretId + ControllerName);
            return(View(data));
        }
Пример #24
0
        public IActionResult GetItem(string Id = null)
        {
            Articles Item           = new Articles();
            string   ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + HttpContext.Request.Headers["UserName"];
            int      IdDC           = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

            if (IdDC > 0)
            {
                Item = ArticlesService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }
            return(Json(Item));
        }
Пример #25
0
        public async Task <IActionResult> SaveItem(IList <IFormFile> files, CategoriesAblums model)
        {
            string ControllerName      = this.ControllerContext.RouteData.Values["controller"].ToString();
            int    IdDC                = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            CategoriesAblumsModel data = new CategoriesAblumsModel()
            {
                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"]);
                    var Cat = CategoriesAblumsService.SaveItem(model);

                    foreach (IFormFile source in files)
                    {
                        string filename = ContentDispositionHeaderValue.Parse(source.ContentDisposition).FileName.Trim('"');

                        filename = this.EnsureCorrectFilename(filename);

                        using (FileStream output = System.IO.File.Create(this.GetPathAndFilename(filename)))
                        {
                            await source.CopyToAsync(output);

                            Ablums alb = new Ablums()
                            {
                                CatId      = Convert.ToInt32(Cat.N),
                                CreatedBy  = model.CreatedBy,
                                ModifiedBy = model.ModifiedBy,
                                Images     = this.GetPathAndFilename(filename)
                            };


                            AblumsService.SaveItem(alb);
                        }
                    }

                    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));
        }
Пример #26
0
        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));
        }
Пример #27
0
        public ActionResult SaveItem(USUsers model)
        {
            string       ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int          IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            USUsersModel data           = new USUsersModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    if (model.Id == 0)
                    {
                        if (model.Password == null || model.Password == null)
                        {
                            model.Password = "******";
                        }
                        model.Password = USUsersService.GetMD5(model.Password);
                    }
                    dynamic DataSave = USUsersService.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"));
                }
            }
            else
            {
                data.ListItemsGroups = USGroupsService.GetListSelectItems();
                data.ListItemsStatus = USUsersService.GetStatusSelectItems();
                data.ListDMCoQuan    = DMCoQuanService.GetListByLoaiCoQuan(0, 1);
                data.ListDMChucVu    = DMChucVuService.GetListSelectItems();
            }
            return(View(data));
        }
Пример #28
0
        //public IActionResult Regist(string Id )
        //{
        //    if (string.IsNullOrEmpty(Id))
        //        return RedirectToAction("Index");

        //    int TotalItems = 0;

        //    EventsModel data = new EventsModel();
        //    string ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
        //    int IdDC = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString());

        //    data.Item = EventsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);

        //    data.myContact = new ContactsModel() { SearchData = new SearchContacts() { CurrentPage = 1, ItemsPerPage = 500,Type = 3 } };
        //    data.myContact.ListItems = ContactsService.GetListPagination(data.myContact.SearchData, API.Models.Settings.SecretId + ControllerName);
        //    if (data.myContact.ListItems != null && data.myContact.ListItems.Count() > 0)
        //    {
        //        TotalItems = data.myContact.ListItems[0].TotalRows;
        //    }
        //    data.myContact.Pagination = new Models.Partial.PartialPagination() { CurrentPage = data.myContact.SearchData.CurrentPage, ItemsPerPage = data.myContact.SearchData.ItemsPerPage, TotalItems = TotalItems, QueryString = Request.QueryString.ToString() };


        //    return View(data);
        //}

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

            if (IdDC == 0)
            {
                data.Item = new Events()
                {
                    Status = true, DateExpiredShow = DateTime.Now.AddDays(15).ToString("dd/MM/yyyy"), DateExpired = DateTime.Now.AddDays(15)
                };
            }
            else
            {
                data.Item = EventsService.GetItem(IdDC, API.Models.Settings.SecretId + ControllerName);
            }

            return(View(data));
        }
Пример #29
0
        public ActionResult SaveItem(ProductsOrder model)
        {
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            int                IdDC           = Int32.Parse(MyModels.Decode(model.Ids, API.Models.Settings.SecretId + ControllerName).ToString());
            ProductsOrderModel data           = new ProductsOrderModel()
            {
                Item = model
            };

            if (ModelState.IsValid)
            {
                if (model.Id == IdDC)
                {
                    model.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    ProductsOrderService.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";
                    }

                    string Str_Url = HttpContext.Session.GetString("STR_Action_Link_" + ControllerName);
                    if (Str_Url != null && Str_Url != "")
                    {
                        return(Redirect("/Admin/" + this.ControllerContext.RouteData.Values["controller"].ToString() + "/Index" + Str_Url));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            else
            {
                //data.ListStart = ProductsOrderService.GetListStart();
            }
            return(View(data));
        }
Пример #30
0
        public ActionResult RessetPassword(string Id)
        {
            string  ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            USUsers item           = new USUsers()
            {
                Id = Int32.Parse(MyModels.Decode(Id, API.Models.Settings.SecretId + ControllerName).ToString())
            };

            try
            {
                if (item.Id > 0)
                {
                    item.CreatedBy  = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.ModifiedBy = int.Parse(HttpContext.Request.Headers["Id"]);
                    item.Password   = USUsersService.GetMD5("Abc@123");
                    dynamic DataDelete = USUsersService.ChangePassword(item.Id, item.Password);
                    string  Msg        = "Cập nhật mật khẩu thành công. Mật khẩu mặc định là <strong>" + "Abc@123" + "<strong>";
                    return(Json(new MsgSuccess()
                    {
                        Msg = Msg
                    }));
                }
                else
                {
                    string Msg = "Cập nhật mật khẩu Không thành công. Xin vui lòng làm lại";
                    return(Json(new MsgError()
                    {
                        Msg = Msg
                    }));
                }
            }
            catch
            {
                string Msg = "Cập nhật mật khẩu Không thành công. Xin vui lòng làm lại.";
                return(Json(new MsgError()
                {
                    Msg = Msg
                }));
            }
        }