Exemple #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);
            }
        }
 //ADMİN PANELİ
 public List <Category> GetCategoryList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Categories.ToList());
     }
 }
 public Category GetCategoryById(int categoryId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Categories.FirstOrDefault(x => x.Id == categoryId));
     }
 }
        // buraya kadar olan metotlar admin paneli için çalışan metotlar

        //WEB UI
        public List <Category> GetCategoryContentList()
        {
            using (TurizmWebEntities db = new TurizmWebEntities())
            {
                return(db.Categories.Include(e => e.Contents).Include(e => e.Contents.Select(w => w.ContentImages)).ToList());
            }
        }
Exemple #5
0
 public List <User> GetUserList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Users.Include("Role").ToList());
     }
 }
Exemple #6
0
 public User GetUserById(int userId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Users.FirstOrDefault(x => x.Id == userId));
     }
 }
Exemple #7
0
 public Role GetRoleById(int roleid)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Roles.FirstOrDefault(x => x.Id == roleid));
     }
 }
Exemple #8
0
 public int GetServiceCount()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Services.Count());
     }
 }
Exemple #9
0
 public int GetContentCount()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Contents.Count());
     }
 }
Exemple #10
0
 public Service GetServiceById(int serviceId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Services.FirstOrDefault(x => x.Id == serviceId));
     }
 }
Exemple #11
0
 public ContentImage GetImageById(int imageId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.ContentImages.FirstOrDefault(x => x.Id == imageId));
     }
 }
Exemple #12
0
 public List <Role> GetRoleList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Roles.ToList());
     }
 }
Exemple #13
0
 public Slider GetSliderById(int sliderId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Sliders.FirstOrDefault(x => x.Id == sliderId));
     }
 }
Exemple #14
0
 public List <Slider> GetSliderList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Sliders.ToList());
     }
 }
Exemple #15
0
 public int GetCategoryCount()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Categories.Count());
     }
 }
Exemple #16
0
 public List <Content> GetContentList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Contents.Include("ContentImages").Include("Category").ToList());
     }
 }
Exemple #17
0
 public Content GetContentsById(int contentId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Contents.FirstOrDefault(x => x.Id == contentId));
     }
 }
Exemple #18
0
 public List <Service> GetServicesList()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Services.ToList());
     }
 }
Exemple #19
0
 public Content GetContentsDetailById(int contentId)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Contents.Include("ContentImages").Include("Category").FirstOrDefault(x => x.Id == contentId));
     }
 }
Exemple #20
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);
            }
        }
Exemple #21
0
 public int GetUsertCount()
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         return(db.Users.Count());
     }
 }
Exemple #22
0
 public int AddService(Service model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         model.CreatedDate = DateTime.Now;
         db.Services.Add(model);
         result = db.SaveChanges();
         return(result);
     }
 }
Exemple #23
0
 public int AddUser(User model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         int result = 0;
         model.Created_Date = DateTime.Now;
         db.Users.Add(model);
         result = db.SaveChanges();
         return(result);
     }
 }
Exemple #24
0
 public User Login(LoginViewModel loginModel)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         var user = db.Users.FirstOrDefault(x => x.Email == loginModel.Email & x.Password == loginModel.Password);
         if (user != null)
         {
             return(user as User);
         }
         return(null);
     }
 }
Exemple #25
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);
     }
 }
Exemple #26
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);
     }
 }
Exemple #27
0
 public int AddRole(RoleModel model)
 {
     using (TurizmWebEntities db = new TurizmWebEntities())
     {
         Role rl = new Role()
         {
             Role_Name    = model.RolName,
             Created_Date = model.CreatedDate
         };
         int sonuc = 0;
         db.Roles.Add(rl);
         sonuc = db.SaveChanges();
         return(sonuc);
     }
 }
Exemple #28
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);
     }
 }
Exemple #29
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);
     }
 }
Exemple #30
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);
     }
 }