Exemple #1
0
        public List <ArtistsModel> GetFilterArtists(List <ProductSummaryModel> products)
        {
            List <int> artistIds = new List <int>();

            if (products != null && products.Count() > 0)
            {
                artistIds = products.Select(s => s.ArtistId).Distinct().ToList();
                using (var dataContext = new BrownBagDataEntities())
                {
                    var selectedArtists = dataContext.Artists.Where(a => artistIds.Any(b => b == a.Id))
                                          .AsEnumerable()
                                          .Select(s => new ArtistsModel
                    {
                        ArtistsId    = s.Id,
                        Description  = s.Description ?? "",
                        ArtistName   = s.Artists ?? "",
                        PictureURL   = s.PictureURL ?? "",
                        ProductCount = products.Where(a => a.ArtistId == s.Id).Count()
                    }).ToList();
                    return(selectedArtists);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public List <BrandModel> GetFilterBrand(List <ProductSummaryModel> products)
        {
            List <int> brandIds = new List <int>();

            if (products != null && products.Count() > 0)
            {
                brandIds = products.Select(s => s.ManufacturerId).Distinct().ToList();
                using (var dataContext = new BrownBagDataEntities())
                {
                    var selectedBrands = dataContext.Manufacturers.Where(a => brandIds.Any(b => b == a.Id))
                                         .AsEnumerable()
                                         .Select(s => new BrandModel
                    {
                        BrandId      = s.Id,
                        Description  = s.Description ?? "",
                        BrandName    = s.ManufacturerName ?? "",
                        DisplayOrder = s.DisplayOrder ?? 0,
                        PictureURL   = s.PictureURL ?? "",
                        ProductCount = products.Where(a => a.ManufacturerId == s.Id).Count()
                    }).ToList();
                    return(selectedBrands);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public List <VendorsModel> GetFilterVendors(List <ProductSummaryModel> products)
        {
            List <int> vendorIds = new List <int>();

            if (products != null && products.Count() > 0)
            {
                vendorIds = products.Select(s => s.VendorId).Distinct().ToList();
                using (var dataContext = new BrownBagDataEntities())
                {
                    var selectedArtists = dataContext.Vendors.Where(a => vendorIds.Any(b => b == a.Id))
                                          .AsEnumerable()
                                          .Select(s => new VendorsModel
                    {
                        VendorId      = s.Id,
                        Description   = s.Description ?? "",
                        VendorName    = s.VendorName ?? "",
                        PictureURL    = s.PictureURL ?? "",
                        VendorAddress = s.VendorAddress ?? "",
                        VendorEmail   = s.VendorEmail ?? "",
                        ProductCount  = products.Where(a => a.VendorId == s.Id).Count()
                    }).ToList();
                    return(selectedArtists);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        public List <CategoryModel> GetFilterCategory(List <ProductSummaryModel> products)
        {
            List <int> categoryIds = new List <int>();

            if (products != null && products.Count() > 0)
            {
                categoryIds = products.Select(s => s.CategoryId).Distinct().ToList();
                using (var dataContext = new BrownBagDataEntities())
                {
                    var selectedCategories = dataContext.Categories.Where(a => categoryIds.Any(b => b == a.Id)).ToList();
                    var rootIds            = selectedCategories.Select(s => s.RootCategory ?? 0).Distinct().ToList();
                    return(dataContext.Categories.Where(w => rootIds.Any(r => r == w.RootCategory))
                           .AsEnumerable()
                           .Select(s => new CategoryModel
                    {
                        CategoryId = s.Id,
                        CategoryDescription = s.Description ?? "",
                        CategoryName = s.Name ?? "",
                        DisplayOrder = s.Display_Order ?? 0,
                        ParentCategoryId = s.ParentCategoryId ?? 0,
                        PictureUrl = s.PictureUrl ?? "",
                        RootCategoryId = s.RootCategory ?? 0,
                        RootTree = s.TempPID ?? "",
                        ProductCount = products.Where(a => a.CategoryId == s.Id).Count()
                    }).ToList());
                }
            }
            else
            {
                return(null);
            }
        }
 public CustomerSummary GetCustomerByEmail(string email)
 {
     try
     {
         var customerSummary = new CustomerSummary();
         using (var dataContext = new BrownBagDataEntities())
         {
             var customerData = dataContext.Customers.Where(a => a.Email == email).ToList();
             if (customerData != null && customerData.Count() > 0)
             {
                 var otherData = dataContext.CustomerAttributes.Where(a => a.Customer_Email == email).FirstOrDefault();
                 customerSummary.IsVerifiedCustomer    = customerData.Where(a => a.Email == email && a.Active == 1).Count() > 0 ? true : false;
                 customerSummary.CustomerName          = otherData.Customer_Name ?? "";
                 customerSummary.CustomerEmail         = otherData.Customer_Email ?? "";
                 customerSummary.CustomerContactNumber = otherData.Customer_Phone ?? "";
                 customerSummary.CustomerId            = customerData.FirstOrDefault().CustomerGuid.Value;
                 customerSummary.IsExclusiveUser       = (customerData.FirstOrDefault().IsSystemAccount ?? 0) > 0 ? true : false;
             }
             else
             {
                 return(null);
             }
         }
         return(customerSummary);
     }
     catch
     {
         throw;
     }
 }
        public List <BannerModel> GetAllBanners()
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var banners = dataContext.Banners
                                  .Select(s => new BannerModel
                    {
                        Id         = s.Id,
                        Sequences  = s.Sequences == null ? 0 : s.Sequences.Value,
                        BannerLink = s.BannerLink ?? "",
                        BannerText = s.BannerText ?? "",
                        BannerURL  = s.BannerURL ?? ""
                    })
                                  .OrderBy(o => o.Sequences).ToList();

                    return(banners);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #7
0
 public OtpDetail GetUnverifiedOtp(string email)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             DateTime currentTime = DateTime.Now.ToUniversalTime();
             var      latestOtp   = dataContext.OtpDetails
                                    .Where(a => a.Email == email &&
                                           a.IsActive == true &&
                                           a.IsVerified == false &&
                                           a.IssueDate <currentTime && a.ExpiryDate> currentTime)
                                    .OrderByDescending(o => o.Id).FirstOrDefault();
             if (latestOtp != null)
             {
                 return(latestOtp);
             }
             else
             {
                 return(null);
             }
         }
     }
     catch
     {
         throw;
     }
 }
 public bool CustomerLogIn(string deviceId, string password, string email)
 {
     try
     {
         bool isLogin = false;
         using (var dataContext = new BrownBagDataEntities())
         {
             if (!string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
             {
                 var deviceData   = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceId).FirstOrDefault();
                 var customerData = dataContext.Customers.Where(a => a.Email == email).FirstOrDefault();
                 if (customerData != null)
                 {
                     var passwordData = dataContext.CustomerPasswords.Where(a => a.Password == password && a.CustomerId == customerData.CustomerGuid).FirstOrDefault();
                     if (deviceData != null && passwordData != null)
                     {
                         isLogin = true;
                         deviceData.RefCustomerGuid = customerData.CustomerGuid;
                     }
                 }
             }
             isLogin = dataContext.SaveChanges() > 0 ? true : false;
         }
         return(isLogin);
     }
     catch
     {
         throw;
     }
 }
 public bool AddNewAddress(Model.CustomerDetailAttribute customerAddress)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             dataContext.CustomerAttributes.Add(new DataEntity.CustomerAttribute
             {
                 Customer_Id     = customerAddress.Customer_Id,
                 Customer_Email  = customerAddress.Customer_Email,
                 Customer_Phone  = customerAddress.Customer_Phone,
                 OTP_Verified    = 0,
                 Modified_Date   = DateTime.Now.ToUniversalTime(),
                 Customer_Name   = customerAddress.Customer_Name,
                 Customer_Active = customerAddress.Customer_Active,
                 Created_Date    = DateTime.Now.ToUniversalTime(),
                 Created_By      = customerAddress.Customer_Email
             });
             return(dataContext.SaveChanges() > 0 ? true : false);
         }
     }
     catch
     {
         throw;
     }
 }
 public bool CustomerLogOff(string deviceId)
 {
     try
     {
         bool isLogOff = false;
         using (var dataContext = new BrownBagDataEntities())
         {
             if (!string.IsNullOrEmpty(deviceId))
             {
                 var deviceData = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceId).FirstOrDefault();
                 if (deviceData != null)
                 {
                     isLogOff = true;
                     deviceData.RefCustomerGuid = null;
                     deviceData.UpdatedOnUtc    = DateTime.Now.ToUniversalTime();
                 }
             }
             isLogOff = dataContext.SaveChanges() > 0 ? true : false;
         }
         return(isLogOff);
     }
     catch
     {
         throw;
     }
 }
        public DeviceRegistrationModel GetDeviceByDeviceId(string deviceId)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    return(dataContext.DeviceRegistrations
                           .Where(w => w.IMEI_Number == deviceId).AsEnumerable()
                           .Select(s => new DeviceRegistrationModel
                    {
                        AccessToken = s.AccessToken ?? "",

                        Id = s.Id,
                        CustomerGuid = s.RefCustomerGuid != null ? s.RefCustomerGuid.Value.ToString() : "",
                        IMEINumber = s.IMEI_Number,

                        IsActive = s.IsActive,
                        CreatedOn = s.CreatedOnUtc.ToUniversalTime(),
                        UpdatedOn = s.UpdatedOnUtc != null ? s.UpdatedOnUtc.Value : DateTime.Now.ToUniversalTime()
                    })
                           .FirstOrDefault());
                }
            }
            catch
            {
                throw;
            }
        }
        public bool AddDeviceRegistration(DeviceRegistrationModel device)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var deviceRegistration = new DeviceRegistration
                    {
                        AccessToken = device.AccessToken.Trim(),

                        CreatedOnUtc    = DateTime.Now.ToUniversalTime(),
                        IMEI_Number     = device.IMEINumber.Trim(),
                        IsActive        = true,
                        RefCustomerGuid = string.IsNullOrEmpty(device.CustomerGuid) ? (Guid?)null : Guid.Parse(device.CustomerGuid),
                        UpdatedOnUtc    = DateTime.Now.ToUniversalTime()
                    };
                    dataContext.DeviceRegistrations.Add(deviceRegistration);
                    return(dataContext.SaveChanges() > 0 ? true : false);
                }
            }
            catch
            {
                throw;
            }
        }
        public bool EditDeviceRegistration(DeviceRegistrationModel device)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var selectedDevice = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == device.IMEINumber).FirstOrDefault();
                    if (selectedDevice != null)
                    {
                        selectedDevice.AccessToken = device.AccessToken.Trim();

                        selectedDevice.UpdatedOnUtc = DateTime.Now.ToUniversalTime();
                        return(dataContext.SaveChanges() > 0 ? true : false);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #14
0
 public bool AddNewOTP(OtpDetailsModel OtpDetailsModel)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             dataContext.OtpDetails.Add(new DataEntity.OtpDetail
             {
                 Email           = OtpDetailsModel.Email,
                 ExpiryDate      = OtpDetailsModel.ExpiryDate,
                 IsActive        = OtpDetailsModel.IsActive,
                 IsVerified      = OtpDetailsModel.IsVerified,
                 OTP             = OtpDetailsModel.OTP,
                 Prupose         = OtpDetailsModel.Prupose,
                 IssueDate       = OtpDetailsModel.IssueDate,
                 RefCustomerGuid = OtpDetailsModel.RefCustomerGuid
             });
             return(dataContext.SaveChanges() > 0 ? true : false);
         }
     }
     catch
     {
         throw;
     }
 }
 public bool ChangeCustomerPassword(string deviceId, string password, string email)
 {
     try
     {
         bool isSave = false;
         using (var dataContext = new BrownBagDataEntities())
         {
             if (!string.IsNullOrEmpty(deviceId) && string.IsNullOrEmpty(email))
             {
                 var deviceData = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceId).FirstOrDefault();
                 if (deviceData != null)
                 {
                     var passwordDetails = dataContext.CustomerPasswords.Where(a => a.CustomerId == deviceData.RefCustomerGuid).FirstOrDefault();
                     passwordDetails.Password = password;
                 }
             }
             else if (string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(email))
             {
                 var emailData = dataContext.Customers.Where(a => a.Email == email).FirstOrDefault();
                 if (emailData != null)
                 {
                     var passwordDetails = dataContext.CustomerPasswords.Where(a => a.CustomerId == emailData.CustomerGuid
                                                                               ).FirstOrDefault();
                     passwordDetails.Password = password;
                 }
             }
             isSave = dataContext.SaveChanges() > 0 ? true : false;
         }
         return(isSave);
     }
     catch
     {
         throw;
     }
 }
Exemple #16
0
 public CartItemSummary ShowCartItems(string deviceNumber, string cuponCode)
 {
     try
     {
         var items = new List <CartItemDetails>();
         using (var dataContext = new BrownBagDataEntities())
         {
             var userInfo = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNumber).FirstOrDefault();
             if (userInfo != null && userInfo.RefCustomerGuid != null)
             {
                 var cartListItems = dataContext.ShoppingCartItems.Where(a => a.Customer_Id == userInfo.RefCustomerGuid).ToList();
                 if (cartListItems != null && cartListItems.Count() > 0)
                 {
                     cartListItems.ForEach(x =>
                     {
                         var product = dataContext.Products.Where(a => a.Id == x.ProductId).FirstOrDefault();
                         if (product != null)
                         {
                             items.Add(new CartItemDetails
                             {
                                 CurrencyType  = x.Currency ?? "",
                                 Price         = x.ProductPrice ?? 0,
                                 ProductId     = x.ProductId ?? 0,
                                 ProductName   = product.ProductName ?? "",
                                 Stock         = product.Stock ?? 0,
                                 StockStatus   = (product.Stock ?? 0) > 1 ? StockStatus.InStock.GetDescription() : (product.Stock ?? 0) == 1 ? StockStatus.LowStock.GetDescription() : StockStatus.OutOfStock.GetDescription(),
                                 ProductImages = dataContext.ProductImages.Where(b => b.ProductID == product.Id).Select(s => new Model.ProductImage
                                 {
                                     Id = s.Id,
                                     GalleryImageURL = s.GalleryImageURL ?? "",
                                     ImageURL        = s.ImageURL ?? "",
                                     Sequences       = s.Sequences ?? 0,
                                     ThumbImageURL   = s.ThumbImageURL ?? ""
                                 }).ToList()
                             });
                         }
                     });
                     return(new CartItemSummary
                     {
                         CartItems = items,
                         CartCalculation = CalculateCartPrice(items, cuponCode, userInfo.RefCustomerGuid.Value, dataContext)
                     });
                 }
                 else
                 {
                     return(null);
                 }
             }
             else
             {
                 return(null);
             }
         }
     }
     catch
     {
         throw;
     }
 }
        public List <CustomerAddressDetails> GetAddresses(string deviceNo)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var device = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNo).FirstOrDefault();
                    if (device == null)
                    {
                        return(null);
                    }
                    if (device.RefCustomerGuid == null)
                    {
                        return(null);
                    }
                    var addresses = dataContext.Addresses
                                    .Where(a => a.CustomerGUID == device.RefCustomerGuid && a.Status == 1)
                                    .Select(s => new CustomerAddressDetails
                    {
                        City           = s.City ?? "",
                        Country        = s.Country ?? "",
                        Id             = s.Id,
                        State          = s.State ?? "",
                        StreetAddress1 = s.StreetAddress1 ?? "",
                        StreetAddress2 = s.StreetAddress2 ?? "",
                        ZipCode        = s.ZipCode ?? ""
                    }).ToList();

                    var relatedDetails = dataContext.Customers
                                         .Where(a => a.CustomerGuid == device.RefCustomerGuid &&
                                                addresses.Any(b => b.Id == a.ShippingAddress_Id || b.Id == a.BillingAddress_Id))
                                         .ToList();

                    if (relatedDetails != null && relatedDetails.Count() > 0)
                    {
                        addresses.ForEach(x =>
                        {
                            if (relatedDetails.Where(y => y.BillingAddress_Id == x.Id).Count() > 0)
                            {
                                x.UseAsBillingAddress = true;
                            }
                            if (relatedDetails.Where(y => y.ShippingAddress_Id == x.Id).Count() > 0)
                            {
                                x.UseAsShipingAddress = true;
                            }
                        });
                    }


                    return(addresses);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #18
0
        public List <ProductSummaryModel> GetProducts(SearchProductModel search, string deviceNo, bool isFeaturedProducts)
        {
            try
            {
                CurrencyTypeName currencyTypeName = search.CurrencyName;
                using (var dataContext = new BrownBagDataEntities())
                {
                    var isExclusiveUser = CheckExclusiveUser(dataContext, deviceNo.Trim());
                    var ratings         = dataContext.Ratings.GroupBy(g => g.ProductID).Select(s2 => new { ProductId = s2.Key, Average = s2.Average(p => p.Rating1 ?? 0), ReviewCount = s2.Where(w => string.IsNullOrEmpty(w.Review)).Count() }).ToList();
                    var products        = dataContext.Products
                                          .Where(w => (isFeaturedProducts == false || w.IsRental == (isFeaturedProducts == true ? 1 : 0)) &&
                                                 w.Published == 1 &&
                                                 (isExclusiveUser == true || w.IsExclusive == (isExclusiveUser == true ? 1 : 0)) &&
                                                 (search.CategoryIds.Count == 0 || (search.CategoryIds.Any(k => k == (w.CategoryID ?? 0)))) &&
                                                 (search.BrandIds.Count == 0 || (search.BrandIds.Any(k => k == (w.ManufacturerID ?? 0)))) &&
                                                 (search.ArtistIds.Count == 0 || (search.ArtistIds.Any(k => k == (w.ArtistID ?? 0)))) &&
                                                 (search.VendorIds.Count == 0 || (search.VendorIds.Any(k => k == (w.VendorID ?? 0)))) &&
                                                 (search.ProductSearchText == null || search.ProductSearchText == "" || w.FullDescription.Contains(search.ProductSearchText) || w.ShortDescription.Contains(search.ProductSearchText) || w.ProductName.Contains(search.ProductSearchText))
                                                 ).AsEnumerable()
                                          .Select(s => new ProductSummaryModel
                    {
                        Id               = s.Id,
                        CategoryId       = s.CategoryID ?? 0,
                        ManufacturerId   = s.ManufacturerID ?? 0,
                        ArtistId         = s.ArtistID ?? 0,
                        VendorId         = s.VendorID ?? 0,
                        CurrencyType     = currencyTypeName.ToString(),
                        FullDescription  = s.FullDescription ?? "",
                        ProductName      = s.ProductName ?? "",
                        ShortDescription = s.ShortDescription ?? "",
                        Discount         = s.Discount ?? 0,
                        Stock            = s.Stock ?? 0,
                        IsExclusive      = (s.IsExclusive ?? 0) == 1 ? true : false,
                        Price            = (currencyTypeName == CurrencyTypeName.INR) ? s.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? s.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? s.CP_Euro ?? 0 : s.CP_GBP ?? 0,
                        ProductImages    = dataContext.ProductImages.Where(x => x.ProductID == s.Id).Select(s1 => new Model.ProductImage
                        {
                            Id = s1.Id,
                            GalleryImageURL = s1.GalleryImageURL,
                            ImageURL        = s1.ImageURL,
                            ThumbImageURL   = s1.ThumbImageURL,
                            Sequences       = s1.Sequences ?? 0
                        }).OrderBy(o => o.Sequences).ToList(),

                        Rating      = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().Average : 0,
                        ReviewCount = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().ReviewCount : 0,
                    })
                                          .ToList();
                    return(products);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #19
0
 public List <WishListItem> ShowWishListItems(string deviceNumber)
 {
     try
     {
         List <WishListItem> items = new List <WishListItem>();
         using (var dataContext = new BrownBagDataEntities())
         {
             var userInfo = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNumber).FirstOrDefault();
             if (userInfo != null && userInfo.RefCustomerGuid != null)
             {
                 var wishListItems = dataContext.Wishlists.Where(a => a.CustomerGUID == userInfo.RefCustomerGuid.ToString()).ToList();
                 if (wishListItems != null && wishListItems.Count() > 0)
                 {
                     wishListItems.ForEach(x =>
                     {
                         var product = dataContext.Products.Where(a => a.Id == x.ProductID).FirstOrDefault();
                         if (product != null)
                         {
                             items.Add(new WishListItem
                             {
                                 CurrencyType  = x.Currency ?? "",
                                 Price         = x.ProductPrice ?? 0,
                                 ProductId     = x.ProductID ?? 0,
                                 ProductName   = product.ProductName ?? "",
                                 Stock         = product.Stock ?? 0,
                                 StockStatus   = (product.Stock ?? 0) > 1 ? StockStatus.InStock.GetDescription() : (product.Stock ?? 0) == 1 ? StockStatus.LowStock.GetDescription() : StockStatus.OutOfStock.GetDescription(),
                                 ProductImages = dataContext.ProductImages.Where(b => b.ProductID == product.Id).Select(s => new Model.ProductImage
                                 {
                                     Id = s.Id,
                                     GalleryImageURL = s.GalleryImageURL ?? "",
                                     ImageURL        = s.ImageURL ?? "",
                                     Sequences       = s.Sequences ?? 0,
                                     ThumbImageURL   = s.ThumbImageURL ?? ""
                                 }).ToList()
                             });
                         }
                     });
                     return(items);
                 }
                 else
                 {
                     return(null);
                 }
             }
             else
             {
                 return(null);
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #20
0
 public bool AddToCart(int productId, CurrencyTypeName currencyTypeName, string deviceNumber)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             var userInfo = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNumber).FirstOrDefault();
             if (userInfo != null && userInfo.RefCustomerGuid != null)
             {
                 var product = dataContext.Products.Where(a => a.Id == productId).FirstOrDefault();
                 if (product != null)
                 {
                     if (product.Stock > 0)
                     {
                         var itemPrice             = (currencyTypeName == CurrencyTypeName.INR) ? product.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? product.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? product.CP_Euro ?? 0 : product.CP_GBP ?? 0;
                         ShoppingCartItem cartItem = new ShoppingCartItem
                         {
                             CreatedOnUtc = DateTime.Now.ToUniversalTime(),
                             UpdatedOnUtc = DateTime.Now.ToUniversalTime(),
                             Currency     = currencyTypeName.ToString(),
                             Customer_Id  = userInfo.RefCustomerGuid.Value,
                             ProductId    = productId,
                             ProductPrice = itemPrice,
                             Quantity     = 1,
                             RevisedPrice = 0
                         };
                         dataContext.ShoppingCartItems.Add(cartItem);
                         return(dataContext.SaveChanges() > 0 ? true : false);
                     }
                     else
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         throw;
     }
 }
 public List <EmailConfig> GetEmailConfig()
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             return(dataContext.EmailConfigs.ToList());
         }
     }
     catch
     {
         throw;
     }
 }
        public bool AddNewCoustomer(CustomerBasicDetails customerBasicDetails, Guid customerId)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var customer = new BrownBagService.DataAccess.DataEntity.Customer
                    {
                        Active                  = 0,
                        AdminComment            = null,
                        AffiliateId             = 0,
                        IsTaxExempt             = 0,
                        VendorId                = 0,
                        CannotLoginUntilDateUtc = DateTime.Now.ToUniversalTime(),
                        Deleted                 = 0,
                        Email                = customerBasicDetails.Email.Trim(),
                        EmailToRevalidate    = null,
                        Username             = customerBasicDetails.Email.Trim(),
                        CustomerGuid         = customerId,
                        BillingAddress_Id    = null,
                        FailedLoginAttempts  = 0,
                        HasShoppingCartItems = 0,
                        IsSystemAccount      = 0,
                        ShippingAddress_Id   = null,
                        LastActivityDateUtc  = DateTime.Now.ToUniversalTime(),
                        LastIpAddress        = null,
                        LastLoginDateUtc     = null,
                        RequireReLogin       = 0,
                        RegisteredInStoreId  = 1,
                        SystemName           = null,
                        CreatedOnUtc         = DateTime.Now.ToUniversalTime(),
                    };
                    dataContext.Customers.Add(customer);

                    int rowCount = dataContext.SaveChanges();
                    if (rowCount > 0)
                    {
                        dataContext.Customer_CustomerRole_Mapping.Add(new Customer_CustomerRole_Mapping {
                            CustomerRole_Id = 3, Customer_Id = customer.Id
                        });
                    }
                    return(dataContext.SaveChanges() > 0 ? true : false);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #23
0
 public bool VerifyOTP(string otp, string email)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             DateTime currentTime = DateTime.Now.ToUniversalTime();
             var      latestOtp   = dataContext.OtpDetails
                                    .Where(a => a.Email == email &&
                                           a.OTP == otp &&
                                           a.IsActive == true &&
                                           a.IsVerified == false &&
                                           a.IssueDate <currentTime && a.ExpiryDate> currentTime)
                                    .OrderByDescending(o => o.Id).FirstOrDefault();
             if (latestOtp != null)
             {
                 latestOtp.IsActive   = false;
                 latestOtp.IsVerified = true;
                 int rows = dataContext.SaveChanges();
                 if (rows > 0)
                 {
                     var customer = dataContext.Customers.Where(a => a.CustomerGuid == latestOtp.RefCustomerGuid).FirstOrDefault();
                     if (customer != null)
                     {
                         customer.Active = 1;
                         customer.LastActivityDateUtc = DateTime.Now.ToUniversalTime();
                         dataContext.SaveChanges();
                     }
                     var customerProfile = dataContext.CustomerAttributes.Where(a => a.Customer_Id == latestOtp.RefCustomerGuid).FirstOrDefault();
                     if (customerProfile != null)
                     {
                         customerProfile.OTP_Verified  = 1;
                         customerProfile.Modified_Date = DateTime.Now.ToUniversalTime();
                         dataContext.SaveChanges();
                     }
                 }
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #24
0
        private bool CheckExclusiveUser(BrownBagDataEntities dataContext, string deviceNo)
        {
            bool IsExclusiveUser = false;
            var  deviceInfo      = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNo).FirstOrDefault();

            if (deviceInfo != null && deviceInfo.RefCustomerGuid != null)
            {
                var userInfo = dataContext.Customers.Where(a => a.CustomerGuid == deviceInfo.RefCustomerGuid).FirstOrDefault();
                if (userInfo != null)
                {
                    IsExclusiveUser = (userInfo.IsSystemAccount ?? 0) > 0 ? true : false;
                }
            }
            return(IsExclusiveUser);
        }
        public bool DeleteAddress(string deviceNo, int id)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var device = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNo).FirstOrDefault();
                    if (device == null)
                    {
                        return(false);
                    }
                    if (device.RefCustomerGuid == null)
                    {
                        return(false);
                    }
                    var address = dataContext.Addresses
                                  .Where(a => a.Id == id && a.CustomerGUID == device.RefCustomerGuid && a.Status == 1)
                                  .FirstOrDefault();

                    var relatedDetail = dataContext.Customers
                                        .Where(a => a.CustomerGuid == device.RefCustomerGuid &&
                                               a.ShippingAddress_Id == address.Id || a.BillingAddress_Id == address.Id)
                                        .FirstOrDefault();

                    if (relatedDetail != null)
                    {
                        if (relatedDetail.BillingAddress_Id == address.Id)
                        {
                            relatedDetail.BillingAddress_Id = null;
                        }
                        if (relatedDetail.ShippingAddress_Id == address.Id)
                        {
                            relatedDetail.ShippingAddress_Id = null;
                        }
                    }
                    dataContext.Addresses.Remove(address);
                    dataContext.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #26
0
 public List <ProductBasicModel> GetProductSuggestions()
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             return(dataContext.Products.Where(w => (w.Published ?? 0) == 1).Select(s => new ProductBasicModel
             {
                 Id = s.Id,
                 ProductName = s.ProductName ?? ""
             }).ToList());
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #27
0
 public List <RootCategoryModel> GetRootCategories()
 {
     using (var dataContext = new BrownBagDataEntities())
     {
         var rootCategories = dataContext.Categories.Where(a => a.Id == a.RootCategory && a.Published == 1).ToList();
         var allCategories  = dataContext.Categories.Where(a => a.Published == 1).ToList();
         return(rootCategories.Select(s => new RootCategoryModel
         {
             CategoryId = s.Id,
             CategoryDescription = s.Description ?? "",
             CategoryName = s.Name ?? "",
             DisplayOrder = s.Display_Order ?? 0,
             ParentCategoryId = s.ParentCategoryId ?? 0,
             PictureUrl = s.PictureUrl ?? "",
             RootCategoryId = s.RootCategory ?? 0,
             RootTree = s.TempPID ?? "",
             ChildCategories = allCategories.Where(a => a.RootCategory == s.Id).Select(s1 => s1.Id).ToList(),
         }).ToList());
     }
 }
Exemple #28
0
 public bool AddNewCustomerPassword(Guid customerId, string password)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             dataContext.CustomerPasswords.Add(new DataEntity.CustomerPassword
             {
                 CustomerId       = customerId,
                 Password         = password,
                 PasswordFormatId = 1,
                 CreatedOnUtc     = DateTime.Now.ToUniversalTime(),
             });
             return(dataContext.SaveChanges() > 0 ? true : false);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #29
0
        public bool UpdateOTP(OtpDetailsModel OtpDetailsModel)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var otp = dataContext.OtpDetails.Where(a => a.Id == OtpDetailsModel.Id).FirstOrDefault();

                    otp.ExpiryDate = OtpDetailsModel.ExpiryDate;
                    otp.IsActive   = OtpDetailsModel.IsActive;
                    otp.IsVerified = OtpDetailsModel.IsVerified;
                    otp.IssueDate  = OtpDetailsModel.IssueDate;

                    return(dataContext.SaveChanges() > 0 ? true : false);
                }
            }
            catch
            {
                throw;
            }
        }
 public bool DeleteDeviceRegistration(string deviceId)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             var selectedDevice = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceId).FirstOrDefault();
             if (selectedDevice != null)
             {
                 dataContext.DeviceRegistrations.Remove(selectedDevice);
                 return(dataContext.SaveChanges() > 0 ? true : false);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         throw;
     }
 }