Exemplo n.º 1
0
 public IEnumerable <BannerActionView> GetAll()
 {
     try
     {
         List <BannerActionView> banners = new List <BannerActionView>();
         var _lst = DbContext.Banners.Where(x => x.Status == true);
         if (_lst != null && _lst.Count() > 0)
         {
             foreach (var item in _lst)
             {
                 BannerActionView banner = new BannerActionView();
                 banner.Avatar = item.Avatar;
                 banner.Desc   = item.Desc;
                 banner.ID     = item.ID;
                 banner.Status = item.Status;
                 banners.Add(banner);
             }
             return(banners);
         }
         return(null);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 public bool Edit(BannerActionView model)
 {
     try
     {
         var _item = DbContext.Banners.Find(model.ID);
         if (_item != null && _item.ID != 0)
         {
             _item.Desc = model.Desc;
             if (!model.Avatar.Contains("http"))
             {
                 _item.Avatar = "http://localhost:44351/" + model.Avatar;
             }
             else
             {
                 _item.Avatar = model.Avatar;
             }
             _item.Status = model.Status;
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public ActionResult Edit(BannerActionView model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (_bannerBusiness.Edit(model))
             {
                 _bannerBusiness.Save();
                 return(Redirect("/Banner/List"));
             }
         }
         return(View(model));
     }
     catch (Exception)
     {
         return(View(model));
     }
 }
Exemplo n.º 4
0
 public BannerActionView GetEdit(int id)
 {
     try
     {
         var _item = DbContext.Banners.Find(id);
         if (_item != null && _item.ID != 0)
         {
             BannerActionView banner = new BannerActionView();
             banner.Avatar = _item.Avatar;
             banner.Desc   = _item.Desc;
             banner.ID     = _item.ID;
             banner.Status = _item.Status;
             return(banner);
         }
         return(null);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemplo n.º 5
0
 public bool Add(BannerActionView model)
 {
     try
     {
         Banner banner = new Banner();
         if (!model.Avatar.Contains("http"))
         {
             banner.Avatar = "http://localhost:44351/" + model.Avatar;
         }
         else
         {
             banner.Avatar = model.Avatar;
         }
         banner.Desc   = model.Desc;
         banner.Status = model.Status;
         DbContext.Banners.Add(banner);
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public bool Add(BannerActionView model)
 {
     return(_banner.Add(model));
 }
Exemplo n.º 7
0
 public bool Edit(BannerActionView model)
 {
     return(_banner.Edit(model));
 }