public List <CategoryDto> GetAllCategory()
 {
     using (EcommerceDB context = new EcommerceDB())
     {
         var data = context.Categories.Where(x => x.IsActive == true)
                    .Select(x => new CategoryDto
         {
             Id            = x.Id,
             Name          = x.Name,
             Image         = x.Image,
             IsActive      = x.IsActive,
             Subcategories = context.Subcategories.Where(y => y.IsActive && y.CategoryId == x.Id)
                             .Select(y => new SubcategoryDto
             {
                 Name = y.Name,
                 Id   = y.Id,
             }).ToList(),
         }).ToList();
         return(data);
     }
 }
示例#2
0
 public List <ItemfeaturesDto> GetAllItemfeature()
 {
     using (EcommerceDB context = new EcommerceDB())
     {
         var data = context.Itemfeaturess.Where(x => x.IsActive == true)
                    .Select(x => new ItemfeaturesDto
         {
             Id          = x.Id,
             Description = x.Description,
             IsActive    = x.IsActive,
             ItemId      = x.ItemId,
             Item        = new ItemDto
             {
                 Id    = x.Item.Id,
                 Name  = x.Item.Name,
                 Price = x.Item.Price,
             }
         }).ToList();
         return(data);
     }
 }
 public List <SubcategoryDto> GetAllSubcategories()
 {
     using (EcommerceDB context = new EcommerceDB())
     {
         var data = context.Subcategories.Where(x => x.IsActive == true)
                    .Select(x => new SubcategoryDto
         {
             Id         = x.Id,
             Name       = x.Name,
             Image      = x.Image,
             IsActive   = x.IsActive,
             CategoryId = x.CategoryId,
             Category   = new CategoryDto
             {
                 Id   = x.Category.Id,
                 Name = x.Category.Name,
             }
         }).ToList();
         return(data);
     }
 }
 public List <SubcategoryDto> GetAllSubcategoriesInHome(int id)
 {
     using (EcommerceDB context = new EcommerceDB())
     {
         var data = context.Subcategories.Where(x => x.IsActive == true)
                    .Select(x => new SubcategoryDto
         {
             Id         = x.Id,
             Name       = x.Name,
             Image      = x.Image,
             IsActive   = x.IsActive,
             CategoryId = x.CategoryId,
             Category   = new CategoryDto
             {
                 Id   = x.Category.Id,
                 Name = x.Category.Name,
             }
         }).OrderByDescending(x => x.Id).Skip(id).Take(4).ToList();
         return(data);
     }
 }
        public ItemDto GetItemById(long id)
        {
            ItemDto item = new ItemDto();

            using (EcommerceDB context = new EcommerceDB())
            {
                var data = context.Items.FirstOrDefault(x => x.IsActive == true && x.Id == id);
                item.Id            = data.Id;
                item.Name          = data.Name;
                item.Price         = data.Price;
                item.Image         = data.Image;
                item.IsActive      = data.IsActive;
                item.CategoryId    = data.CategoryId;
                item.SubcategoryId = data.SubcategoryId;
                item.BrandId       = data.BrandId;
                item.Brand         = new BrandDto
                {
                    Id   = data.Brand.Id,
                    Name = data.Brand.Name,
                };
                item.Category = new CategoryDto
                {
                    Id   = data.Category.Id,
                    Name = data.Category.Name,
                };
                item.Subcategory = new SubcategoryDto

                {
                    Id   = data.Subcategory.Id,
                    Name = data.Subcategory.Name,
                };
                item.Itemfeatures = context.Itemfeaturess.Where(x => x.IsActive == true && x.ItemId == item.Id)
                                    .Select(x => new ItemfeaturesDto
                {
                    Id          = x.Id,
                    Description = x.Description,
                }).OrderByDescending(x => x.Id).ToList();
            }
            return(item);
        }
        public DataSourceResult ItemsInView(DataSourceRequest Request)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var dataSourceResult = context.Items.Where(x => x.IsActive == true)
                                       .Select(x => new ItemDto
                {
                    Id            = x.Id,
                    Name          = x.Name,
                    Image         = x.Image,
                    Price         = x.Price,
                    IsActive      = x.IsActive,
                    BrandId       = x.BrandId,
                    CategoryId    = x.CategoryId,
                    SubcategoryId = x.SubcategoryId,
                    Brand         = new BrandDto
                    {
                        Id    = x.Brand.Id,
                        Name  = x.Brand.Name,
                        Image = x.Brand.Image
                    },
                    Category = new CategoryDto
                    {
                        Id   = x.Category.Id,
                        Name = x.Category.Name
                    },
                    Subcategory = new SubcategoryDto
                    {
                        Id   = x.Subcategory.Id,
                        Name = x.Subcategory.Name
                    }
                }).OrderByDescending(x => x.Id).ToDataSourceResult(Request);

                DataSourceResult kendoResponseDto = new DataSourceResult();
                kendoResponseDto.Data       = dataSourceResult.Data;
                kendoResponseDto.Total      = dataSourceResult.Total;
                kendoResponseDto.Aggregates = dataSourceResult.Aggregates;
                return(kendoResponseDto);
            }
        }
        public List <ItemDto> SearchItemByKeyword(string Keyword)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var data = context.Items.Where(x => x.IsActive == true &&
                                               (x.Name.Contains(Keyword) || Keyword.Contains(x.Name) || x.Category.Name.Contains(Keyword) || x.Subcategory.Name.Contains(Keyword) || x.Brand.Name.Contains(Keyword)))
                           .Select(x => new ItemDto
                {
                    Id       = x.Id,
                    Name     = x.Name,
                    Price    = x.Price,
                    Image    = x.Image,
                    IsActive = x.IsActive,

                    CategoryId = x.CategoryId,
                    Category   = new CategoryDto
                    {
                        Id   = x.Category.Id,
                        Name = x.Category.Name
                    },

                    SubcategoryId = x.SubcategoryId,
                    Subcategory   = new SubcategoryDto
                    {
                        Id   = x.Subcategory.Id,
                        Name = x.Subcategory.Name
                    },

                    BrandId = x.BrandId,
                    Brand   = new BrandDto
                    {
                        Id   = x.Brand.Id,
                        Name = x.Brand.Name
                    }
                }).OrderByDescending(x => x.Id).ToList();

                return(data);
            }
        }
示例#8
0
        public DataSourceResult FilterBookingreportInView(FilterDto Request)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var data = context.Bookings.Where(x => x.IsActive == true);
                if (Request.CategoryIds.Count() > 0)
                {
                    data = data.Where(x => Request.CategoryIds.Contains(x.Item.CategoryId));
                }
                if (Request.BrandIds.Count() > 0)
                {
                    data = data.Where(x => Request.BrandIds.Contains(x.Item.BrandId));
                }
                var dataSourceResult = data.Where(x => (DbFunctions.TruncateTime(x.Date)) >= (DbFunctions.TruncateTime(Request.Fromdate)) && (DbFunctions.TruncateTime(x.Date)) <= (DbFunctions.TruncateTime(Request.Todate)))
                                       .Select(x => new BookingDto
                {
                    Id       = x.Id,
                    Name     = x.Name,
                    Date     = x.Date,
                    Address  = x.Address,
                    Remarks  = x.Remarks,
                    MobileNo = x.MobileNo,
                    EmailId  = x.EmailId,
                    IsActive = x.IsActive,

                    ItemId = x.ItemId,
                    Item   = new ItemDto
                    {
                        Id   = x.Item.Id,
                        Name = x.Item.Name
                    },
                }).OrderByDescending(x => x.Id).ToDataSourceResult(Request);

                DataSourceResult kendoResponseDto = new DataSourceResult();
                kendoResponseDto.Data  = dataSourceResult.Data;
                kendoResponseDto.Total = dataSourceResult.Total;
                return(kendoResponseDto);
            }
        }
示例#9
0
        public List <ItemfeaturesDto> GetItemFeaturesByItemId(long id)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var dataSourceResult = context.Itemfeaturess.Where(x => x.IsActive == true && x.ItemId == id)
                                       .Select(x => new ItemfeaturesDto
                {
                    Id          = x.Id,
                    Description = x.Description,
                    IsActive    = x.IsActive,
                    ItemId      = x.ItemId,
                    Item        = new ItemDto
                    {
                        Id    = x.Item.Id,
                        Name  = x.Item.Name,
                        Price = x.Item.Price,
                    }
                }).OrderByDescending(x => x.Id).ToList();


                return(dataSourceResult);
            }
        }
        public List <ItemDto> GetItemBySubcategoryId(long id)
        {
            using (EcommerceDB context = new EcommerceDB())
            {
                var dataSourceResult = context.Items.Where(x => x.IsActive == true && x.SubcategoryId == id)
                                       .Select(x => new ItemDto
                {
                    Id       = x.Id,
                    IsActive = x.IsActive,
                    Name     = x.Name,
                    Image    = x.Image,
                    Price    = x.Price,
                    BrandId  = x.BrandId,
                    Brand    = new BrandDto
                    {
                        Id    = x.Brand.Id,
                        Name  = x.Brand.Name,
                        Image = x.Brand.Image
                    },
                    CategoryId = x.CategoryId,
                    Category   = new CategoryDto
                    {
                        Id   = x.Category.Id,
                        Name = x.Category.Name
                    },
                    SubcategoryId = x.SubcategoryId,
                    Subcategory   = new SubcategoryDto
                    {
                        Id   = x.Subcategory.Id,
                        Name = x.Subcategory.Name
                    }
                }).OrderByDescending(x => x.Id).ToList();


                return(dataSourceResult);
            }
        }
示例#11
0
 public bool AddItemfeature(ItemfeaturesDto dataDto)
 {
     if (dataDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             if (dataDto.Id <= 0)
             {
                 Itemfeatures AddData = new Itemfeatures();
                 AddData.Description = dataDto.Description;
                 AddData.ItemId      = dataDto.ItemId;
                 AddData.IsActive    = true;
                 context.Itemfeaturess.Add(AddData);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 var olddata = context.Itemfeaturess.FirstOrDefault(x => x.Id == dataDto.Id);
                 if (olddata != null)
                 {
                     olddata.Description = dataDto.Description;
                     olddata.IsActive    = true;
                     context.Entry(olddata).Property(x => x.Description).IsModified = true;
                     olddata.ItemId = dataDto.ItemId;
                     context.Entry(olddata).Property(x => x.ItemId).IsModified   = true;
                     context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                     olddata.IsActive = true;
                     context.SaveChanges();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public bool AddNewlaunchproduct(NewlaunchproductDto dataDto)
 {
     if (dataDto != null)
     {
         using (EcommerceDB context = new EcommerceDB())
         {
             if (dataDto.Id <= 0)
             {
                 Newlaunchproduct AddData = new Newlaunchproduct();
                 AddData.NewlaunchId = dataDto.NewlaunchId;
                 AddData.ItemId      = dataDto.ItemId;
                 AddData.IsActive    = true;
                 context.Newlaunchproducts.Add(AddData);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 var olddata = context.Newlaunchproducts.FirstOrDefault(x => x.Id == dataDto.Id);
                 if (olddata != null)
                 {
                     olddata.IsActive = true;
                     context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                     olddata.NewlaunchId = dataDto.NewlaunchId;
                     context.Entry(olddata).Property(x => x.NewlaunchId).IsModified = true;
                     olddata.ItemId = dataDto.ItemId;
                     context.Entry(olddata).Property(x => x.ItemId).IsModified = true;
                     olddata.IsActive = true;
                     context.SaveChanges();
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
示例#13
0
        public bool AddGallery(GalleryDto dataDto)
        {
            if (dataDto != null)
            {
                using (EcommerceDB context = new EcommerceDB())
                {
                    if (dataDto.Id <= 0)
                    {
                        Gallery AddData = new Gallery();
                        AddData.Name = dataDto.Name;
                        if (dataDto.Img1 != null && dataDto.Img1 != "" && AddData.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && AddData.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img1.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            AddData.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                        }

                        AddData.IsActive = true;
                        context.Gallerys.Add(AddData);
                        context.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        var olddata = context.Gallerys.FirstOrDefault(x => x.Id == dataDto.Id);
                        if (olddata != null)
                        {
                            olddata.Name = dataDto.Name;
                            if (dataDto.Img1 != null && dataDto.Img1 != "" && olddata.Img1 != dataDto.Img1 && !dataDto.Img1.Contains("http"))
                            {
                                Guid   id      = Guid.NewGuid();
                                var    imgData = dataDto.Img1.Substring(dataDto.Img1.IndexOf(",") + 1);
                                byte[] bytes   = Convert.FromBase64String(imgData);
                                Image  image;
                                using (MemoryStream ms = new MemoryStream(bytes))
                                {
                                    image = Image.FromStream(ms);
                                }
                                Bitmap b        = new Bitmap(image);
                                string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                                b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                                olddata.Img1 = string.Concat("UploadedFiles\\" + id + ".jpg");
                                context.Entry(olddata).Property(x => x.Img1).IsModified = true;
                            }
                        }
                        if (dataDto.Img2 != null && dataDto.Img2 != "" && olddata.Img2 != dataDto.Img2 && !dataDto.Img2.Contains("http"))
                        {
                            Guid   id      = Guid.NewGuid();
                            var    imgData = dataDto.Img2.Substring(dataDto.Img2.IndexOf(",") + 1);
                            byte[] bytes   = Convert.FromBase64String(imgData);
                            Image  image;
                            using (MemoryStream ms = new MemoryStream(bytes))
                            {
                                image = Image.FromStream(ms);
                            }
                            Bitmap b        = new Bitmap(image);
                            string filePath = System.Web.HttpContext.Current.Server.MapPath("~") + "UploadedFiles\\" + id + ".jpg";
                            b.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                            olddata.Img2 = string.Concat("UploadedFiles\\" + id + ".jpg");
                            context.Entry(olddata).Property(x => x.Img2).IsModified = true;
                        }
                        olddata.IsActive = true;
                        context.Entry(olddata).Property(x => x.Name).IsModified = true;

                        context.Entry(olddata).Property(x => x.IsActive).IsModified = true;
                        olddata.IsActive = true;
                        context.SaveChanges();
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#14
0
 public LoginController(EcommerceDB context)
 {
     _context = context;
 }
 public LoaiSPController(EcommerceDB context)
 {
     _context = context;
 }
示例#16
0
 public SanPhamController(EcommerceDB context)
 {
     _context = context;
 }