Ejemplo n.º 1
0
        public ActionResult UpdateCollection(int id = 0)
        {
            CollectionBO model = new CollectionBO();

            if (id > 0)
            {
                model = CollectionDAO.GetCollectionByID(id);
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult UpdateCollection(CollectionBO collectionModel)
        {
            if (ModelState.IsValid)
            {
                UserLogin user         = (UserLogin)Session[CommonConstants.USER_SESSION];
                string    errorMessage = "";
                bool      result       = false;
                collectionModel.isdeleted = 0;
                if (collectionModel.id > 0)
                {
                    //get updatemodel
                    CollectionBO newUpdateBO = new CollectionBO();
                    newUpdateBO = CollectionDAO.GetCollectionByID(collectionModel.id);
                    if (newUpdateBO == null)
                    {
                        ModelState.AddModelError("", "Collection không tồn tại");
                        return(View(collectionModel));
                    }

                    newUpdateBO.updateduser     = user.UserID.ToString();
                    newUpdateBO.updateddate     = DateTime.Now;
                    newUpdateBO.description     = collectionModel.description;
                    newUpdateBO.keyword         = collectionModel.keyword;
                    newUpdateBO.logo            = collectionModel.logo;
                    newUpdateBO.metadescription = collectionModel.metadescription;
                    newUpdateBO.metakeyword     = collectionModel.metakeyword;
                    newUpdateBO.name            = collectionModel.name;
                    newUpdateBO.seoname         = collectionModel.seoname;
                    newUpdateBO.displayorder    = collectionModel.displayorder;

                    result = CollectionDAO.UpdateCollection(newUpdateBO, ref errorMessage);
                    SetAlert($"Cập nhật Collection {collectionModel.id}-{collectionModel.name} thành công", "success");
                }
                else
                {
                    collectionModel.createduser = user.UserID.ToString();
                    collectionModel.createddate = DateTime.Now;
                    result = CollectionDAO.InsertCollection(collectionModel, ref errorMessage);
                    SetAlert($"Thêm Collection {collectionModel.name} thành công", "success");
                }

                if (result)
                {
                    return(RedirectToAction("Collection", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Có lỗi xảy ra. Thêm thất bại: " + errorMessage);
                }
            }

            return(View(collectionModel));
        }
Ejemplo n.º 3
0
        public ActionResult Collection(string metatitle, int id, string orderby = "")
        {
            if (metatitle.Length <= 0 && metatitle.Split('-').Count() < 2)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            var collectionInfo = CollectionDAO.GetCollectionByID(id);

            if (collectionInfo == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }

            var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo");

            ViewBag.OrderBy    = orderby;
            ViewBag.CommonInfo = commonInfo;
            return(View(collectionInfo));
        }