public ActionResult AddBanner(Banner banner)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Banners.InsertOnSubmit(banner);
     db.SubmitChanges();
     return RedirectToAction("ListBanners");
 }
        public ActionResult CreateIn(FormCollection collection, Banner banner)
        {
            try
            {
                // TODO: Add insert logic here

                if (!ModelState.IsValid || Request.Files[0].ContentLength == 0)
                {
                    if (Request.Files[0].ContentLength == 0) ViewData.ModelState.AddModelError("Image", "Phải chọn hình");
                    return View(banner);
                }


                string fileName = "No files";
                fileName = Request.Files[0].FileName;
                Request.Files[0].SaveAs(Path.Combine(DBNLConfigurationManager.FileResponsity.BannerFolder, fileName));
                banner.Status = EntityStatuses.Actived.ToString();
                banner.BannerImage = fileName;
                banner.CreatedDate = DateTime.Now;
                banner.UpdatedDate = DateTime.Now;

                new BannerService().Add(banner);
                return RedirectToAction("List");
            }
            catch (Exception ex)
            {
                throw ex;
                //return View();
            }
        }
 public ActionResult EditBanner(int id, Banner banner)
 {
     DBNLDataContext db = new DBNLDataContext();
     Banner updBanner = db.Banners.Where(p => p.Id == id).SingleOrDefault();
     updBanner.BannerImage = banner.BannerImage;
     updBanner.BannerPosition = banner.BannerPosition;
     updBanner.CreatedDate = banner.CreatedDate;
     updBanner.Name = banner.Name;
     updBanner.Status = banner.Status;
     updBanner.UpdatedDate = banner.UpdatedDate;
     updBanner.Url = banner.Url;
     db.SubmitChanges();
     return RedirectToAction("ListBanners");
 }
 partial void DeleteBanner(Banner instance);
 partial void UpdateBanner(Banner instance);
 partial void InsertBanner(Banner instance);