Esempio n. 1
0
        public List <ImagesModel> GetCompletedProject()
        {
            List <ImagesModel> models = new List <ImagesModel>();

            try
            {
                using (var entity = new dehunEntities())
                {
                    List <GroupImage> groups = (from g in entity.GroupImages
                                                where g.Active == 1
                                                select g).ToList();
                    List <Images> images = (from i in entity.Images1
                                            where i.Active == (int)Active.Show
                                            select i)
                                           .ToList();
                    foreach (var item in groups)
                    {
                        ImagesModel model = new ImagesModel();
                        model.group  = item;
                        model.images = images.Where(r => r.GroupId == item.Id).ToList();
                        models.Add(model);
                    }
                    return(models);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public List <GroupProduct> GetWedo()
        {
            //List<ServicesModel> lstModel = new List<ServicesModel>();
            try
            {
                using (var entity = new dehunEntities())
                {
                    List <GroupProduct> groups = (from g in entity.GroupProducts
                                                  where g.Active == (int)Active.Show && g.Priority == (int)Active.Show && g.Position == 1
                                                  select g).ToList();
                    //List<Product> Wedo = (from p in entity.Products
                    //                      join g in entity.GroupProducts on p.GroupId equals g.Id
                    //                      where g.Active == (int)Active.Show && p.Active == (int)Active.Show && g.Priority == (int)Active.Show
                    //                      select p)
                    //                      .ToList();
                    //for (int i = 0; i < groups.Count; i++)
                    //{
                    //    ServicesModel model = new ServicesModel();
                    //    if (i == 0)
                    //    {
                    //        model.classname = "active";
                    //    }
                    //    model.group = groups[i];
                    //    model.products = Wedo.Where(r => r.GroupId == groups[i].Id).ToList();
                    //    lstModel.Add(model);
                    //}

                    return(groups);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        public ActionResult Contact()
        {
            try
            {
                using (var entity = new dehunEntities())
                {
                    Config config = entity.Configs.FirstOrDefault();
                    if (config != null)
                    {
                        ViewBag.Location = config.Contact;
                    }
                    List <Support> support = entity.Supports.Where(r => r.Active == (int)Active.Show).ToList();

                    if (support.Count > 0)
                    {
                        ViewBag.Phone = support[0].Phone;
                        ViewBag.Email = support[0].Email;
                        for (int i = 1; i < support.Count; i++)
                        {
                            ViewBag.Phone += " - " + support[i].Phone;
                            ViewBag.Email += " - " + support[i].Email;
                        }
                    }
                }

                return(View());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        public ProductsListModel()
        {
            List <GroupProduct> groups;

            try
            {
                productsModel    = new List <Product>();
                productsAllModel = new List <ProductsModel>();
                productsOther    = new ProductsModel();
                using (var entity = new dehunEntities())
                {
                    ProductsModel model;
                    GroupProduct  group = entity.GroupProducts.Where(r => r.Priority == 1 && r.Active == 1).FirstOrDefault();
                    productsModel = entity.Products.Where(r => r.Active == 1 && r.IsHot == 1 && !string.IsNullOrEmpty(r.Image1)).ToList();

                    groups = entity.GroupProducts.Where(r => r.Active == 1).ToList();
                    foreach (var item in groups)
                    {
                        model          = new ProductsModel();
                        model.group    = item;
                        model.products = entity.Products.Where(r => r.Active == 1 && r.GroupId == item.Id && !string.IsNullOrEmpty(r.Image1)).ToList();
                        if (model.products.Count > 0)
                        {
                            productsAllModel.Add(model);
                        }
                    }
                    productsOther.group    = group;
                    productsOther.products = entity.Products.Where(r => r.GroupId == group.Id && r.Active == 1 && !string.IsNullOrEmpty(r.Image1)).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 5
0
 // GET: Page
 public ActionResult Detail(int id)
 {
     using (dehunEntities entity = new dehunEntities())
     {
         Page page = entity.Pages.Where(r => r.Id == id).FirstOrDefault();
         ViewBag.Title = page.Name;
         return(View(page));
     }
 }
 public ProductDetailModel(int id)
 {
     try
     {
         using (var entity = new dehunEntities())
         {
             product        = entity.Products.SingleOrDefault(r => r.Id == id);
             productsRelate = entity.Products.Where(r => r.GroupId == product.GroupId && r.Active == 1 && r.Id != id && !string.IsNullOrEmpty(r.Image1)).Take(10).ToList();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 7
0
 public ServiceListModel(int id)
 {
     using (dehunEntities entity = new dehunEntities())
     {
         servicesModel = new ServicesModel();
         groups        = (from g in entity.GroupProducts
                          where g.Active == (int)Active.Show && g.Position == 1
                          select g).ToList();
         servicesModel.group = groups.SingleOrDefault(r => r.Id == id);
         groups.Remove(servicesModel.group);
         servicesModel.products = (from p in entity.Products
                                   where p.Active == (int)Active.Show && p.GroupId == id
                                   select p).ToList();
     }
 }
Esempio n. 8
0
 public ImagesModel()
 {
     try
     {
         images = new List <Images>();
         using (var entity = new dehunEntities())
         {
             List <Images> images = entity.Images1.Where(r => r.Priority == 1 && r.Active == 1).ToList();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 9
0
 public void Contact(Contact contact)
 {
     try
     {
         using (var entity = new dehunEntities())
         {
             contact.Date = DateTime.Now;
             entity.Contacts.Add(contact);
             entity.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 10
0
 public ProductsModel(int id)
 {
     try
     {
         using (var entity = new dehunEntities())
         {
             group = entity.GroupProducts.SingleOrDefault(r => r.Id == id);
             List <int> groups = entity.GroupProducts.Where(r => r.Level.StartsWith(group.Level) && r.Active == 1).Select(r => r.Id).ToList();
             products = entity.Products.AsEnumerable().Where(r => r.Active == 1 && groups.Any(c => c.CompareTo(r.GroupId) == 0 && !string.IsNullOrEmpty(r.Image1))).ToList();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 11
0
 public List <Advertise> GetSlider()
 {
     try
     {
         using (var entity = new dehunEntities())
         {
             List <Advertise> Slider = (from a in entity.Advertises
                                        where a.Position == (int)BannerPosition.Slider && a.Active == (int)Active.Show
                                        select a)
                                       .ToList();
             return(Slider);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 12
0
        public List <News> GetHomeNews()
        {
            try
            {
                using (var entity = new dehunEntities())
                {
                    List <News> homenews = (from n in entity.News
                                            where n.Active == (int)Active.Show && n.Priority == (int)Active.Show
                                            select n)
                                           .ToList();

                    return(homenews);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 13
0
        public List <Page> GetHomeServices()
        {
            try
            {
                using (var entity = new dehunEntities())
                {
                    List <Page> homeservice = (from p in entity.Pages
                                               where p.Active == (int)Active.Show && p.Position.Contains(((int)PagePosition.MiddlePage).ToString())
                                               select p)
                                              .ToList();

                    return(homeservice);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 14
0
 public ServiceDetailModel(int id)
 {
     using (dehunEntities entity = new dehunEntities())
     {
         productRelate = (from p in entity.Products
                          where p.Active == (int)Active.Show &&
                          p.GroupId == (from s in entity.Products
                                        where s.Id == id
                                        select s.GroupId).FirstOrDefault()
                          select p).ToList();
         product = productRelate.Where(r => r.Id == id).FirstOrDefault();
         productRelate.Remove(product);
         newsRelate = entity.News.Where(r => r.Active == 1 &&
                                        !string.Empty.Equals(r.LinkDemo) &&
                                        r.LinkDemo.Contains("'" + product.Id.ToString() + "'"))
                      .OrderByDescending(r => r.Date)
                      .ToList();
     }
 }
Esempio n. 15
0
 public FooterModel()
 {
     using (dehunEntities entity = new dehunEntities())
     {
         about = (from p in entity.Pages
                  where p.Active == (int)Active.Show && p.Position.Contains(((int)PagePosition.About).ToString())
                  select p).FirstOrDefault();
         List <Page> pages = (from p in entity.Pages
                              where p.Active == (int)Active.Show && p.Position.Contains(((int)PagePosition.Menu_Bottom).ToString())
                              orderby p.Level
                              select p).ToList();
         menuBottom = new List <Page>();
         foreach (Page item in pages.Where(r => r.Level.Length == 5).ToList())
         {
             menuBottom.Add(item);
         }
         address = ((Config)HttpContext.Current.Session["config"]).Contact;
         support = ((Support)HttpContext.Current.Session["support"]);
     }
 }
Esempio n. 16
0
 public NewsModel(int id)
 {
     try
     {
         using (var entity = new dehunEntities())
         {
             group = (from g in entity.GroupNews
                      where g.Active == (int)Active.Show && g.Id == id
                      select g).FirstOrDefault();
             news = (from n in entity.News
                     where n.Active == (int)Active.Show && n.GroupNewsId == id
                     orderby n.Date descending
                     select n).ToList();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }