Esempio n. 1
0
        public ActionResult Edit(FormCollection form)
        {
            string writeMsg = string.Empty;
            Advert item     = new Advert();

            item.ID         = int.Parse(Request.Form["ID"]);
            item.Title      = Request.Form["Title"];
            item.Content    = form["Content"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.ClickUrl   = HtmlContentHelper.GetFirstUrl(item.Content);
            EnterRepository.GetRepositoryEnter().AdvertRepository.Get(m => m.ID == item.ID);
            bool result = EnterRepository.GetRepositoryEnter().AdvertRepository.EditEntity(item, new string[] { "Title", "CategoryID", "Content", "ModifyID", "ModifyTime", "ImagePath", "ClickUrl" });

            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "修改成功!";
            }
            else
            {
                writeMsg = "修改失败!";
            }
            return(Content(writeMsg));
        }
Esempio n. 2
0
        public ActionResult Edit(FormCollection form)
        {
            string writeMsg = string.Empty;
            Book   item     = new Book();

            item.ID         = int.Parse(Request.Form["ID"]);
            item.Title      = Request.Form["Title"];
            item.Keywords   = Request.Form["Keywords"];
            item.Content    = form["Content"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.Summary    = HtmlContentHelper.GetSummary(item.Content);
            item.Url        = HtmlContentHelper.GetFirstUrl(item.Content);
            item.Price      = form["Price"] != null?float.Parse(form["Price"]) : 0;

            item.DisCount = form["DisCount"] != null?float.Parse(form["DisCount"]) : 0;

            EnterRepository.GetRepositoryEnter().BookRepository.Get(m => m.ID == item.ID);
            bool result = EnterRepository.GetRepositoryEnter().BookRepository.EditEntity(item, new string[] { "Title", "Keywords", "CategoryID", "Content", "ModifyID", "ModifyTime", "ImagePath", "Summary", "Price", "DisCount", "Url" });

            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "修改成功!";
            }
            else
            {
                writeMsg = "修改失败!";
            }
            return(Content(writeMsg));
        }
Esempio n. 3
0
        public ActionResult Add(FormCollection form)
        {
            string writeMsg = string.Empty;
            Advert item     = new Advert();

            item.Title      = Request.Form["Title"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.Content    = form["Content"];
            item.CreateID   = WebCookieHelper.GetEmployeeId();
            item.CreateTime = DateTime.Now;
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.ClickUrl   = HtmlContentHelper.GetFirstUrl(item.Content);
            EnterRepository.GetRepositoryEnter().AdvertRepository.AddEntity(item);
            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "{msg:\"保存成功!\",id:" + item.ID.ToString() + "}";
            }
            else
            {
                writeMsg = "{msg:\"保存失败!\",id:0}";
            }
            return(Content(writeMsg));
        }
Esempio n. 4
0
        public ActionResult Add(FormCollection form)
        {
            string writeMsg = string.Empty;
            Book   item     = new Book();

            item.Title      = Request.Form["Title"];
            item.Keywords   = Request.Form["Keywords"];
            item.CategoryID = int.Parse(Request.Form["CategoryID"]);
            item.Content    = form["Content"];
            item.CreateID   = WebCookieHelper.GetEmployeeId();
            item.CreateTime = DateTime.Now;
            item.ModifyID   = WebCookieHelper.GetEmployeeId();
            item.ModifyTime = DateTime.Now;
            item.ImagePath  = HtmlContentHelper.GetFirstImgUrl(item.Content);
            item.Summary    = HtmlContentHelper.GetSummary(item.Content);
            item.Url        = HtmlContentHelper.GetFirstUrl(item.Content);
            item.Price      = form["Price"] != null?float.Parse(form["Price"]) : 0;

            item.DisCount = form["DisCount"] != null?float.Parse(form["DisCount"]) : 0;

            EnterRepository.GetRepositoryEnter().BookRepository.AddEntity(item);
            if (EnterRepository.GetRepositoryEnter().SaveChange() > 0)
            {
                writeMsg = "{msg:\"保存成功!\",id:" + item.ID.ToString() + "}";
            }
            else
            {
                writeMsg = "{msg:\"保存失败!\",id:0}";
            }
            return(Content(writeMsg));
        }