public bool Add(Banner item)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             item.DateTimeCreate = DateTime.Now;
             item.GuidCreate = Guid.NewGuid();
             _context.Banners.Add(item);
             _context.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
 public bool Disable(Banner item)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             Banner banner = _context.Banners.FirstOrDefault(c => c.Id == item.Id);
             if (banner != null)
             {
                 banner.IsActive = false;
                 banner.DateTimeModify = DateTime.Now;
                 banner.GuidModify = Guid.NewGuid();
                 _context.SaveChanges();
                 return true;
             }
             return false;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public bool Update(Models.User item)
        {
            try
            {
                using (_context = new GreenhouseBannerContext())
                {
                    User user = this._context.Users.FirstOrDefault(c => c.Id == item.Id);
                    if (user != null)
                    {
                        var account = System.Web.HttpContext.Current.Session["Account"] as Account;
                        user.UserModifyId = account.UserId;
                        user.Username = item.Username;
                        user.Name = item.Name;
                        user.Email = item.Email;
                        //user.Password = MD5Helper.Encrypt(item.Password);
                        user.Password = MD5Helper.Encrypt(item.Password, true);
                        user.ModifyDate = DateTime.Now;
                        user.IdRole = item.IdRole;
                        _context.SaveChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
 public bool IsActive(Guid id)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             User user = _context.Users.FirstOrDefault(c => c.Id == id);
             if (user != null)
             {
                 user.IsActive = !user.IsActive;
                 user.ModifyDate = DateTime.Now;
                 var account = System.Web.HttpContext.Current.Session["Account"] as Account;
                 user.UserModifyId = account.UserId;
                 _context.SaveChanges();
                 return true;
             }
             return false;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public bool Update(Banner item)
        {
            try
            {
                using (_context  = new GreenhouseBannerContext())
                {
                    Banner banner = this._context.Banners.FirstOrDefault(c => c.Id == item.Id);
                    if (banner != null)
                    {
                        banner.BannerName = item.BannerName;
                        banner.BannerImage = item.BannerImage;
                        banner.IsActive = item.IsActive;
                        banner.Position = item.Position;
                        banner.Link = item.Link;
                        banner.BannerDescription = item.BannerDescription;
                        banner.DateTimeModify = DateTime.Now;
                        banner.GuidModify = Guid.NewGuid();
                        _context.SaveChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
 public bool IsActive(int id)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             Role role = _context.Roles.FirstOrDefault(c => c.Id == id);
             if (role != null)
             {
                 role.IsActive = !role.IsActive;
                 _context.SaveChanges();
                 return true;
             }
             return false;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public bool Update(Role item)
        {
            try
            {
                using (_context = new GreenhouseBannerContext())
                {
                    Role user = this._context.Roles.FirstOrDefault(c => c.Id == item.Id);
                    if (user != null)
                    {
                        user.RoleName = item.RoleName;
                        _context.SaveChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }
 public bool IsActive(int id)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             TitleRightBanner title = _context.TitleRightBanners.FirstOrDefault(c => c.ID == id);
             if (title != null)
             {
                 var account = System.Web.HttpContext.Current.Session["Account"] as Account;
                 title.UserModifyId = account.UserId;
                 title.IsActive = !title.IsActive;
                 title.ModifyDate = DateTime.Now;
                 _context.SaveChanges();
                 return true;
             }
             return false;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
 public bool UpdateSTT(RightBanner item)
 {
     try
     {
         using (_context = new GreenhouseBannerContext())
         {
             RightBanner bannerRight = _context.RightBanners.FirstOrDefault(c => c.Id == item.Id);
             if (bannerRight != null)
             {
                 var account = System.Web.HttpContext.Current.Session["Account"] as Account;
                 bannerRight.UserModifyId = account.UserId;
                 bannerRight.STT = item.STT;
                 bannerRight.ModifyDate = DateTime.Now;
                 _context.SaveChanges();
                 return true;
             }
             return false;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public bool Update(Models.RightBanner item)
        {
            try
            {
                using (_context = new GreenhouseBannerContext())
                {
                    RightBanner bannerRight = this._context.RightBanners.FirstOrDefault(c => c.Id == item.Id);
                    if (bannerRight != null)
                    {
                        var account = System.Web.HttpContext.Current.Session["Account"] as Account;
                        bannerRight.UserModifyId = account.UserId;
                        bannerRight.Name = item.Name;
                        bannerRight.PlanName = item.PlanName;
                        bannerRight.Unit = item.Unit;
                        bannerRight.Link = item.Link;
                        bannerRight.ModifyDate = DateTime.Now;
                        _context.SaveChanges();
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                return false;
            }
        }