Beispiel #1
0
        public ActionResult Edit(int id, EditNewsModel model, FormCollection collection, HttpPostedFileBase PreviewImage)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    News ns = new News();
                    ns.CopyPropertiesFrom(model);
                    ns.News_CategoryID = model.CategoryId;

                    NewsService service = new NewsService();
                    ns.UpdatedUserID = SessionManager.UserInfo.UserID;
                    service.Edit(ns, PreviewImage);
                    return RedirectToAction("Index");
                }
            }
            catch (Exception ex) {
                ModelState.AddModelError("Error500", "Có lỗi hệ thống - không cập nhật được dữ liệu.");
            }

            return View(model);
        }
Beispiel #2
0
        public ActionResult Edit(int id)
        {
            NewsService service = new NewsService();
            var data= service.FirstOrDefault(p=>p.NewsID == id);
            EditNewsModel model = new EditNewsModel();

            model.CopyPropertiesFrom(data);
            model.CategoryId = data.News_CategoryID;
            return View(model);
        }