Example #1
0
        public int DeleteContent(int contentId)
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                int result  = 0;
                var content = GetContentsById(contentId);

                if (content != null)
                {
                    var images = db.ContentImages.Where(x => x.Content_Id == content.Id).ToList();

                    if (images.Count > 0)
                    {
                        foreach (var item in images)
                        {
                            db.Entry(item).State = EntityState.Deleted;
                            db.ContentImages.Remove(item);
                            db.SaveChanges();
                        }
                    }


                    db.Entry(content).State = EntityState.Deleted;
                    db.Contents.Remove(content);
                    result = db.SaveChanges();
                }
                return(result);
            }
        }
Example #2
0
        public int UpdateContent(Content model)
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                int result  = 0;
                var content = GetContentsById(model.Id);
                if (content != null)
                {
                    content.Title        = model.Title;
                    content.Detail       = model.Detail;
                    content.IsActive     = model.IsActive;
                    content.Panel        = model.Panel;
                    content.Price        = model.Price;
                    content.Location     = model.Location;
                    content.StartDate    = model.StartDate;
                    content.FinishDate   = model.FinishDate;
                    content.Rate         = model.Rate;
                    content.NumberPeople = model.NumberPeople;
                    content.Category_Id  = model.Category_Id;

                    db.Entry(content).State = EntityState.Modified;
                    result = db.SaveChanges();
                }
                return(result);
            }
        }
Example #3
0
 public int DeleteService(int serviceId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result  = 0;
         var service = GetServiceById(serviceId);
         if (service != null)
         {
             db.Entry(service).State = System.Data.Entity.EntityState.Deleted;
             db.Services.Remove(service);
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #4
0
 public int UpdateRole(Role model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         var role   = GetRoleById(model.Id);
         if (role != null)
         {
             role.Role_Name       = model.Role_Name;
             db.Entry(role).State = System.Data.Entity.EntityState.Modified;
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #5
0
 public int DeleteRole(int id)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         var role   = GetRoleById(id);
         if (role != null)
         {
             db.Entry(role).State = System.Data.Entity.EntityState.Deleted;
             db.Roles.Remove(role);
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #6
0
 public int DeleteSlider(int id)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         var slider = GetSliderById(id);
         if (slider != null)
         {
             db.Entry(slider).State = System.Data.Entity.EntityState.Deleted;
             db.Sliders.Remove(slider);
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #7
0
 public int DeleteCategory(int categoryid)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result   = 0;
         var category = GetCategoryById(categoryid);
         if (category != null)
         {
             db.Entry(category).State = EntityState.Deleted;
             db.Categories.Remove(category);
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #8
0
 public bool DeleteContentImage(int id)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         bool result = false;
         var  image  = GetImageById(id);
         if (image != null)
         {
             db.Entry(image).State = EntityState.Deleted;
             db.ContentImages.Remove(image);
             int resultx = db.SaveChanges();
             result = resultx == 1 ? true : false;
         }
         return(result);
     }
 }
Example #9
0
 public int UpdateSlider(Slider model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         var slider = GetSliderById(model.Id);
         if (slider != null)
         {
             slider.Title           = model.Title;
             slider.Description     = model.Description;
             db.Entry(slider).State = System.Data.Entity.EntityState.Modified;
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #10
0
 public int UpdateCategory(Category model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result    = 0;
         var category_ = GetCategoryById(model.Id);
         if (category_ != null)
         {
             category_.Name            = model.Name;
             category_.Description     = model.Description;
             db.Entry(category_).State = EntityState.Modified;
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #11
0
        public int UpdateService(Service model)
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                int result  = 0;
                var service = GetServiceById(model.Id);
                if (service != null)
                {
                    service.Title  = model.Title;
                    service.Detail = model.Detail;

                    db.Entry(service).State = System.Data.Entity.EntityState.Modified;
                    result = db.SaveChanges();
                }
                return(result);
            }
        }
Example #12
0
        public int UpdateUser(User model)
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                int result = 0;
                var user   = GetUserById(model.Id);
                if (user != null)
                {
                    user.First_Name = model.First_Name;
                    user.Last_Name  = model.Last_Name;
                    user.Phone      = model.Phone;
                    user.Email      = model.Email;
                    user.Password   = model.Password;
                    user.Role_Id    = model.Role_Id;

                    db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    result = db.SaveChanges();
                }
                return(result);
            }
        }
Example #13
0
 public int UpdateStatus(int id)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result  = 0;
         var content = GetContentsById(id);
         if (content != null)
         {
             if (content.IsActive == true)
             {
                 content.IsActive = false;
             }
             else
             {
                 content.IsActive = true;
             }
             db.Entry(content).State = EntityState.Modified;
             result = db.SaveChanges();
         }
         return(result);
     }
 }
Example #14
0
        public int UpdateContentImage(ContentImage model, HttpPostedFileBase newimage)
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                int result = 0;
                //object modelImage = model.Original_Image_Path;
                //HttpPostedFileBase img = modelImage as HttpPostedFileBase;
                if (newimage != null)
                {
                    string newImagePath = new GlobalHelper().saveImage(newimage, model.Original_Image_Path);

                    var image = GetImageById(model.Id);
                    if (image != null)
                    {
                        image.Original_Image_Path = newImagePath;

                        db.Entry(image).State = EntityState.Modified;
                        result = db.SaveChanges();
                    }
                }
                return(result);
            }
        }