コード例 #1
0
        public BSEntityFramework_ResultType GetShopAddress(int shopId)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var shopAddress = EF.TBL_Shops.Where(shop => shop.ShopID == shopId)
                                      .Select(
                        shop => shop.ShopAddress)
                                      .First();

                    var result = new BSEntityFramework_ResultType(BSResult.Success, shopAddress, null, "Success");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, null));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Shop Address Failed Retrived", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #2
0
 public bool IsValidShopForUser(int userID, int ShopId)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var isValidShopChange = EF.TBL_ShopLoginDetails
                                     .Where(sld => sld.ShopLoginDetailsID == userID)
                                     .Join(EF.TBL_UserAssignedShops, sld => sld.ShopLoginDetailsID, uas => uas.ShopLoginDetailsID,
                                           (sld, uas) => new { sld.ShopLoginDetailsID, uas.ShopID, uas.IsActive })
                                     .Where(UAS => UAS.IsActive == true)
                                     .Join(EF.TBL_Shops, us => us.ShopID, ts => ts.ShopID,
                                           (us, ts) => new { ShopId = ts.ShopID, ShopName = ts.ShopName, isActive = ts.IsActive }).Any(x => x.isActive);
             return(isValidShopChange);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(false);
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, userID, null, "Technical issue");
         logact.ErrorSetup("WebApp", "Shop Change IsValid Failed", "", "", "", ex.Message);
         return(false);
     }
 }
コード例 #3
0
        public BSEntityFramework_ResultType InsertTop5ProductForShop(List <TBL_Shops5TopProducts> top5List)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    foreach (TBL_Shops5TopProducts p in top5List)
                    {
                        EF.TBL_Shops5TopProducts.Add(p);
                    }
                    EF.SaveChanges();
                }

                var result = new BSEntityFramework_ResultType(BSResult.Success, null, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, null));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, top5List, null, "Technical issue");
                logact.ErrorSetup("WebApp", "InsertState Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #4
0
        public BSEntityFramework_ResultType GetOfferImage(int shopId, int offerId)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var offerImage = EF.TBL_ShopOffers.FirstOrDefault(p => p.OfferID == offerId);
                    var result     = new BSEntityFramework_ResultType(BSResult.Success,
                                                                      new ImageDetails()
                    {
                        ImgID   = offerImage?.OfferID ?? -1,
                        ImgData = offerImage != null ? String.Format("data:image/jpg;base64,{0}",
                                                                     Convert.ToBase64String(offerImage.OfferImage != null? offerImage.OfferImage : new byte[] {})) : null
                    },
                                                                      null, "Updated Successfully");

                    return(result);
                }
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Fetch Product Image Failed", "", "", "", ex.Message);
                return(null);
            }
        }
コード例 #5
0
        public IEnumerable <ShopAssignedToUser> GetShopAssignedList(string userID)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var shopList = EF.TBL_ShopLoginDetails.Where(sld => sld.LoginName == userID)
                                   .Join(EF.TBL_UserAssignedShops, sld => sld.ShopLoginDetailsID, uas => uas.ShopLoginDetailsID,
                                         (sld, uas) => new { sld.ShopLoginDetailsID, uas.ShopID, uas.IsActive })
                                   .Where(UAS => UAS.IsActive == true)
                                   .Join(EF.TBL_Shops, us => us.ShopID, ts => ts.ShopID,
                                         (us, ts) => new ShopAssignedToUser()
                    {
                        ShopId = ts.ShopID, ShopName = ts.ShopName
                    })
                                   .ToArray();

                    return(shopList);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(null);
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, userID, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Shop list Failed", "", "", "", ex.Message);
                return(null);
            }
        }
コード例 #6
0
        public BSEntityFramework_ResultType InsertShopTypes(TBL_ShopTypes_CNFG newShopTypes)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    EF.TBL_ShopTypes_CNFG.Add(newShopTypes);
                    EF.SaveChanges();
                }

                var result = new BSEntityFramework_ResultType(BSResult.Success, newShopTypes, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, newShopTypes));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, newShopTypes, null, "Technical issue");
                logact.ErrorSetup("WebApp", "InsertShopTypes Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #7
0
 public BSEntityFramework_ResultType GetInfrastructureByPostal(string postalCode)
 {
     try
     {
         var pinCode = Convert.ToInt32(postalCode);
         using (BSDBEntities EF = new BSDBEntities())
         {
             var Infrastructure =
                 EF.TBL_Infrastructure_CNFG.Where(inf => inf.PostalCodeID == pinCode)
                 .Select(inf => new { inf.InfrastructureID, inf.InfrastructureName }).ToArray();
             var result = new BSEntityFramework_ResultType(BSResult.FailForValidation, Infrastructure, null, "Success");
             return(result);
         }
     }
     catch (InvalidCastException dbValidationEx)
     {
         var result = new BSEntityFramework_ResultType(BSResult.FailForValidation, null, null, "Invalid Postal Code");
         return(result);
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetInfrastructure Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #8
0
        public BSEntityFramework_ResultType InsertOffersonProduct(List <TBL_OfferOnProducts> offeronProducts, int offerid)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    foreach (var product in offeronProducts)
                    {
                        product.OfferID = offerid;
                        EF.TBL_OfferOnProducts.Add(product);
                    }
                    EF.SaveChanges();
                }

                var result = new BSEntityFramework_ResultType(BSResult.Success, offeronProducts, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, offeronProducts));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, offeronProducts, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Insert Offers on Product Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #9
0
        public BSEntityFramework_ResultType InsertProductImages(List <TBL_ProductImages> productImages, long productid)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    foreach (var prodimage in productImages)
                    {
                        prodimage.ProductID = productid;
                        EF.TBL_ProductImages.Add(prodimage);
                    }
                    EF.SaveChanges();
                }

                var result = new BSEntityFramework_ResultType(BSResult.Success, productImages, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, productImages));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, productImages, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Insert ProductImages Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #10
0
ファイル: Plugins_Activity.cs プロジェクト: Raj-Bhalekar/zroo
 public IEnumerable <MenuVM> GetPluginMenuDetailList(int userId, int shopId)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var menus = EF.TBL_PlugIns.Where(x => x.IsActive == true)
                         .Join(EF.TBL_Shop_PlugIn
                               , x => x.PlugInID
                               , sp => sp.PlugInID
                               , (x, sp) => new { x.PlugInID, sp.ShopID, x.IsFreeToAll }
                               ).Where(sp => sp.ShopID == shopId || sp.IsFreeToAll == true)
                         // .Join(EF.TBL_Shops,x=>x.ShopID,ts=>ts.ShopID,(x,ts)=>new {x.PlugInID,ts.ShopID})
                         .Join(EF.TBL_Page_Plugins,
                               x => x.PlugInID, y => y.PlugInID,
                               (x, y) => new { x.PlugInID, y.PageID })
                         .Join(EF.TBL_Page_Menues
                               , p => p.PageID, m => m.PageID,
                               (p, m) => new { p.PageID, p.PlugInID, m.MenuID })
                         .Join(EF.TBL_Menues, pm => pm.MenuID
                               , mid => mid.MenuID, (pm, mid) => new { pm.PageID, mid.MenuName, mid.MenuID, mid.ParentMenuId, mid.MenuIconPath })
                         .Join(EF.TBL_Pages, pmid => pmid.PageID, TP => TP.PageID, (pmid, TP) => new MenuVM()
             {
                 PageId       = pmid.PageID,
                 MenuName     = pmid.MenuName,
                 MenuURL      = TP.PageURL,
                 ParentMenuId = pmid.ParentMenuId.Value,
                 MenuID       = pmid.MenuID,
                 MenuIconPath = pmid.MenuIconPath
             }).Select(u => u)
                         .Union(EF.TBL_Menues.Where(mainMenu => mainMenu.ParentMenuId == null).Select(
                                    mms => new MenuVM()
             {
                 PageId       = 0,
                 MenuName     = mms.MenuName,
                 MenuURL      = "#",
                 ParentMenuId = 0,
                 MenuID       = mms.MenuID,
                 MenuIconPath = mms.MenuIconPath
             }
                                    ))
                         .ToArray();
             // var result = new BSEntityFramework_ResultType(BSResult.Success, Menus, null,
             //"Success");
             return(menus);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(null);
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, userId, null, "Technical issue");
         logact.ErrorSetup("WebApp", "Menu list Failed", "", "", "", ex.Message);
         return(null);
     }
 }
コード例 #11
0
        public BSEntityFramework_ResultType InsertShopMapDetails(TBL_ShopMapDetails shopsMapDetails)
        {
            try
            {
                BSEntityFramework_ResultType result;
                using (BSDBEntities EF = new BSDBEntities())
                {
                    using (var transaction = EF.Database.BeginTransaction())
                    {
                        try
                        {
                            EF.Database.CommandTimeout = 180;

                            if (shopsMapDetails.CreateDate == DateTime.MinValue)
                            {
                                shopsMapDetails.CreateDate = DateTime.Now;
                                EF.TBL_ShopMapDetails.Add(shopsMapDetails);
                            }
                            else
                            {
                                EF.TBL_ShopMapDetails.Attach(shopsMapDetails);
                                EF.Entry(shopsMapDetails).Property(x => x.Latitude).IsModified   = true;
                                EF.Entry(shopsMapDetails).Property(x => x.Longitude).IsModified  = true;
                                EF.Entry(shopsMapDetails).Property(x => x.UpdateDate).IsModified = true;
                                EF.Entry(shopsMapDetails).Property(x => x.UpdatedBy).IsModified  = true;
                            }

                            EF.SaveChanges();
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            var logact = new LoggerActivity();
                            result = new BSEntityFramework_ResultType(BSResult.Fail, shopsMapDetails, null, "Technical issue");
                            logact.SaveLog(logact.ErrorSetup("WebApp", "shops Map Details Failed", "", "", "", ex.Message));
                            return(result);
                        }
                    }
                }
                result = new BSEntityFramework_ResultType(BSResult.Success, shopsMapDetails, null,
                                                          "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, shopsMapDetails));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, shopsMapDetails, null, "Technical issue");
                logact.SaveLog(logact.ErrorSetup("WebApp", "shops Map Details Failed", "", "", "", ex.Message));
                return(result);
            }
        }
コード例 #12
0
ファイル: BSActivity.cs プロジェクト: Raj-Bhalekar/zroo
        public BSEntityFramework_ResultType FormatException(DbEntityValidationException dbValidationEx, object entity)
        {
            var errorMessages = dbValidationEx.EntityValidationErrors
                                .SelectMany(x => x.ValidationErrors)
                                .Select(x => x.ErrorMessage);

            var result = new BSEntityFramework_ResultType(BSResult.FailForValidation, entity, errorMessages, "Validation Failed");

            return(result);
        }
コード例 #13
0
        public BSEntityFramework_ResultType GetProductList(int shopId, string brand, string sortColumnName, string sortOrder, int pageSize, int currentPage)
        {
            var List        = new object();
            int totalPage   = 0;
            int totalRecord = 0;

            using (BSDBEntities EF = new BSDBEntities())
            {
                var prod =
                    string.IsNullOrWhiteSpace(brand) || brand == "0"?
                    EF.TBL_Products.Where(prd => prd.ShopID == shopId && prd.IsActive)
                    :
                    EF.TBL_Products.Where(prd => prd.ShopID == shopId && prd.IsActive &&
                                          prd.ProductBrand.Equals(brand)
                                          );


                var prodListBS = prod.Select(prd => new { prd.ProductID, prd.ProductName,
                                                          prd.ProductBrand,
                                                          prd.BarCode,
                                                          prd.IsAvailable
                                                          , prd.MRP,
                                                          prd.ShopPrice,
                                                          prd.OtherJsonDetails
                                                          , prd.TBL_ProductCategories_CNFG.ProductCategoryName,
                                                          prd.TBL_ProductType_CNFG.ProductTypeName,
                                                          prd.TBL_ProductSubType_CNFG.ProductSubTypeName }).ToArray();
                totalRecord    = prodListBS.Length;
                sortColumnName = sortColumnName ?? "ProductID";
                if (pageSize > 0)
                {
                    totalPage = totalRecord / pageSize + ((totalRecord % pageSize) > 0 ? 1 : 0);
                    List      = prodListBS
                                .OrderBy(sortColumnName + " " + sortOrder)
                                .Skip(pageSize * (currentPage - 1))
                                .Take(pageSize).ToArray();
                }
                else
                {
                    var prodList = prodListBS.ToArray();
                    List = prodList;
                }
            }

            var jsonresult = new JsonResult
            {
                Data = new { List = List, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            var result = new BSEntityFramework_ResultType(BSResult.Success, List, null, "Fetched Successfully");

            return(result);
        }
コード例 #14
0
        public BSEntityFramework_ResultType InsertProducts(AddProductViewModel newProduct)
        {
            try
            {
                BSEntityFramework_ResultType result;
                using (BSDBEntities EF = new BSDBEntities())
                {
                    using (var transaction = EF.Database.BeginTransaction())
                    {
                        try
                        {
                            var shopId        = newProduct.ProductDetails.ShopID;
                            var totalProducts = EF.TBL_Products.Count(x => x.ShopID == shopId) + 1;
                            newProduct.ProductDetails.ProductID
                                = CommonSafeConvert.ToInt(Convert.ToString(shopId) + Convert.ToString(totalProducts));
                            newProduct.ProductDetails.TBL_ProductImages = newProduct.ProductImages;
                            EF.TBL_Products.Add(newProduct.ProductDetails);
                            EF.SaveChanges();
                            //var resultChild = InsertProductImages(newProduct.ProductImages,
                            //    newProduct.ProductDetails.ProductID);
                            //if (resultChild.Result != BSResult.Success)
                            //{
                            //    return resultChild;
                            //}
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            var logact = new LoggerActivity();
                            result = new BSEntityFramework_ResultType(BSResult.Fail, newProduct, null, "Technical issue");
                            logact.ErrorSetup("WebApp", "InsertShope Failed", "", "", "", ex.Message);
                            return(result);
                        }
                    }

                    result = new BSEntityFramework_ResultType(BSResult.Success, newProduct.ProductDetails, null,
                                                              "Created Sucessfully");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, newProduct.ProductDetails));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, newProduct.ProductDetails, null,
                                                              "Technical issue");
                logact.ErrorSetup("WebApp", "Insert Products Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #15
0
        public BSEntityFramework_ResultType InsertShope(AddShopViewModel newShop)
        {
            try
            {
                BSEntityFramework_ResultType result;
                using (BSDBEntities EF = new BSDBEntities())
                {
                    using (var transaction = EF.Database.BeginTransaction())
                    {
                        try
                        {
                            newShop.ShopDetails.ShopID = -1;
                            newShop.ShopDetails.TBL_UserAssignedShops.Add(new TBL_UserAssignedShops()
                            {
                                ShopLoginDetailsID = newShop.ShopDetails.CreatedBy, CreatedBy = newShop.ShopDetails.CreatedBy, IsActive = true
                            });
                            newShop.ShopDetails.TBL_ShopsInPostalCodes.Add(newShop.ShopPostalDetails);
                            EF.TBL_Shops.Add(newShop.ShopDetails);
                            EF.SaveChanges();

                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            transaction.Rollback();
                            var logact = new LoggerActivity();
                            result = new BSEntityFramework_ResultType(BSResult.Fail, newShop, null, "Technical issue");
                            logact.ErrorSetup("WebApp", "InsertShope Failed", "", "", "", ex.Message);
                            return(result);
                        }
                    }
                }

                result = new BSEntityFramework_ResultType(BSResult.Success, newShop, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, newShop));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, newShop, null, "Technical issue");
                logact.ErrorSetup("WebApp", "InsertShope Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #16
0
        public BSEntityFramework_ResultType GetShopMapDetails(int shopId)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var shopMapDetails = EF.TBL_ShopMapDetails.Where(x => x.ShopId == shopId)
                                         .Select(x => new
                    {
                        ShopId     = x.ShopId,
                        Latitude   = x.Latitude,
                        Longitude  = x.Longitude,
                        CreateBy   = x.CreateBy,
                        CreateDate = x.CreateDate
                    }).First();
                    var shopAddress = EF.TBL_Shops.Where(shop => shop.ShopID == shopId)
                                      .Select(
                        shop => shop.ShopAddress)
                                      .First();

                    var result = new BSEntityFramework_ResultType(BSResult.Success, new MapAddressViewModel()
                    {
                        Address        = shopAddress,
                        shopMapDetails = new TBL_ShopMapDetails()
                        {
                            ShopId     = shopMapDetails.ShopId,
                            Latitude   = shopMapDetails.Latitude,
                            Longitude  = shopMapDetails.Longitude,
                            CreateBy   = shopMapDetails.CreateBy,
                            CreateDate = shopMapDetails.CreateDate
                        }
                    }, null, "Success");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, null));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
                logact.ErrorSetup("WebApp", "Get Shop Map details Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #17
0
 public BSEntityFramework_ResultType ValidateLogin(string userId)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var Userid = EF.TBL_ShopLoginDetails.Where(p => p.LoginName == userId).Select(x => x.ShopLoginDetailsID).First();
             if (Userid > 0)
             {
                 Plugins_Activity obj = new Plugins_Activity();
                 var menus            = obj.GetPluginMenuDetailList(userId);
                 var shopAssignedList = GetShopAssignedList(userId);
                 var rslt             = new LoginResult()
                 {
                     UserId           = Userid,
                     IsValid          = true,
                     MenuDetailList   = menus,
                     ShopAssignedList = shopAssignedList
                 };
                 var result = new BSEntityFramework_ResultType(BSResult.Success, rslt, null, "Success");
                 return(result);
             }
             return(new BSEntityFramework_ResultType(BSResult.Success, new LoginResult()
             {
                 UserId = 0,
                 IsValid = false,
                 MenuDetailList = null,
                 ShopAssignedList = null
             }
                                                     ,
                                                     null, "Success"));
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "Signin Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #18
0
        public BSEntityFramework_ResultType GetShopAllBrands(int shopId)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var brandList = EF.TBL_Products.Where(prod => prod.ShopID == shopId)
                                    .Select(
                        prod => new { Text = prod.ProductBrand, Value = prod.ProductBrand })
                                    .Distinct()
                                    .ToArray()
                                    .Select(
                        ptype =>
                        new SelectListItem()
                    {
                        Text = ptype.Text, Value = Convert.ToString(ptype.Value)
                    })
                                    .ToArray();


                    SelectListItem[] DefaultItem =
                    {
                        new SelectListItem()
                        {
                            Text  = "Select Brand",
                            Value = "0"
                        }
                    };
                    var finalBrands = DefaultItem.Concat(brandList).OrderBy(v => v.Value).ToArray();
                    var result      = new BSEntityFramework_ResultType(BSResult.Success, finalBrands, null, "Success");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, null));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
                logact.ErrorSetup("WebApp", "GetProductSubType Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #19
0
        public BSEntityFramework_ResultType UpdateProducts(AddProductViewModel Products)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    // EF.TBL_Products.AddOrUpdate(Products.ProductDetails);
                    EF.TBL_Products.Attach(Products.ProductDetails);
                    EF.Entry(Products.ProductDetails).Property(x => x.IsActive).IsModified          = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.AvailableQuantity).IsModified = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.BarCode).IsModified           = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.IsAvailable).IsModified       = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.MRP).IsModified = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.OtherJsonDetails).IsModified  = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ProductBrand).IsModified      = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ProductCategoryID).IsModified = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ProductName).IsModified       = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ProductSubTypeID).IsModified  = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ProductTypeID).IsModified     = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ShopPrice).IsModified         = true;
                    EF.Entry(Products.ProductDetails).Property(x => x.ShopID).IsModified            = false;

                    if (Products.ProductImages != null && Products.ProductImages.Count > 0 && Products.ProductImages[0] != null)
                    {
                        EF.TBL_ProductImages.Attach(Products.ProductImages[0]);
                        EF.Entry(Products.ProductImages[0]).Property(x => x.ProductImage).IsModified = true;
                    }
                    EF.SaveChanges();
                    var result = new BSEntityFramework_ResultType(BSResult.Success, Products, null, "Updated Successfully");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, Products));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, Products, null, "Technical issue");
                logact.ErrorSetup("WebApp", "UpdateProducts Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #20
0
        public BSEntityFramework_ResultType GetShopTypes()
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var ShopTypes =
                        EF.TBL_ShopTypes_CNFG.Select(
                            shoptype => new { Text = shoptype.TypeName, Value = shoptype.ShopTypeID })
                        .ToList()
                        .Select(
                            shptype =>
                            new SelectListItem()
                    {
                        Text = shptype.Text, Value = Convert.ToString(shptype.Value)
                    })
                        .ToArray();

                    SelectListItem[] DefaultItem =
                    {
                        new SelectListItem()
                        {
                            Text  = "Select Shop Type",
                            Value = "0"
                        }
                    };

                    var finalShopTypes = DefaultItem.Concat(ShopTypes).OrderBy(v => v.Value).ToArray();
                    var result         = new BSEntityFramework_ResultType(BSResult.Success, finalShopTypes, null, "Success");
                    return(result);
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, null));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
                logact.ErrorSetup("WebApp", "GetShopTypes Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #21
0
 public BSEntityFramework_ResultType InsertShopInPostal(TBL_ShopsInPostalCodes shopsInPostal, int shopID)
 {
     try
     {
         BSEntityFramework_ResultType result;
         using (BSDBEntities EF = new BSDBEntities())
         {
             using (var transaction = EF.Database.BeginTransaction())
             {
                 try
                 {
                     EF.Database.CommandTimeout = 180;
                     shopsInPostal.ShopID       = shopID;
                     EF.TBL_ShopsInPostalCodes.Add(shopsInPostal);
                     EF.SaveChanges();
                     transaction.Commit();
                 }
                 catch (Exception ex)
                 {
                     transaction.Rollback();
                     var logact = new LoggerActivity();
                     result = new BSEntityFramework_ResultType(BSResult.Fail, shopsInPostal, null, "Technical issue");
                     logact.SaveLog(logact.ErrorSetup("WebApp", "InsertShopPostalDetails Failed", "", "", "", ex.Message));
                     return(result);
                 }
             }
         }
         result = new BSEntityFramework_ResultType(BSResult.Success, shopsInPostal, null,
                                                   "Created Sucessfully");
         return(result);
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, shopsInPostal));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, shopsInPostal, null, "Technical issue");
         logact.SaveLog(logact.ErrorSetup("WebApp", "InsertShopPostalDetails Failed", "", "", "", ex.Message));
         return(result);
     }
 }
コード例 #22
0
        public BSEntityFramework_ResultType SignUp(TBL_ShopLoginDetails model)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    if (EF.TBL_ShopLoginDetails.Any(x => (x.LoginName == model.LoginName)))
                    {
                        var result = new BSEntityFramework_ResultType(BSResult.Success, model, null, "Login Name already exist");
                        return(result);
                    }
                    else if (EF.TBL_ShopLoginDetails.Any(x => (x.EmailID == model.EmailID)))
                    {
                        var result = new BSEntityFramework_ResultType(BSResult.Success, model, null, "Email ID already exist");
                        return(result);
                    }
                    else
                    {
                        EF.TBL_ShopLoginDetails.Add(model);
                        EF.SaveChanges();

                        var result = new BSEntityFramework_ResultType(BSResult.Success, model, null, "Created Sucessfully");
                        return(result);
                    }
                }
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, model));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, model, null, "Technical issue");
                logact.ErrorSetup("WebApp", "InsertShopOffer Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #23
0
 public BSEntityFramework_ResultType GetShopTypes(int id)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var ShopTypes = EF.TBL_ShopTypes_CNFG.Find(id);
             var result    = new BSEntityFramework_ResultType(BSResult.Success, ShopTypes, null, "Success");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetShopTypes Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #24
0
 public BSEntityFramework_ResultType GetShops5TopProducts(int id)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var Top5Productlist = EF.TBL_Shops5TopProducts.Where(sht => sht.ShopID == id).ToArray();
             var result          = new BSEntityFramework_ResultType(BSResult.Success, Top5Productlist, null, "Success");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetState Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #25
0
 public BSEntityFramework_ResultType GetAllShope()
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var Shop   = EF.TBL_ShopLoginDetails.Select(bs => bs).ToArray();
             var result = new BSEntityFramework_ResultType(BSResult.Success, Shop, null, "Success");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetShope Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #26
0
 public BSEntityFramework_ResultType GetALLStates()
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var states = EF.TBL_States_CNFG.Select(st => st).ToArray();
             var result = new BSEntityFramework_ResultType(BSResult.Success, states, null, "Success");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetState Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #27
0
        public BSEntityFramework_ResultType InsertShopOffer(AddShopOffersViewModel newShopOffer)
        {
            try
            {
                using (BSDBEntities EF = new BSDBEntities())
                {
                    var shopId      = newShopOffer.ShopOffer.ShopID;
                    var totalOffers = EF.TBL_ShopOffers.Count(x => x.ShopID == shopId) + 1;
                    newShopOffer.ShopOffer.OfferID
                        = CommonSafeConvert.ToInt(Convert.ToString(shopId) + Convert.ToString(totalOffers));
                    foreach (var prod in newShopOffer.OfferonProducts)
                    {
                        prod.CreatedBy  = newShopOffer.ShopOffer.CreatedBy;
                        prod.CreateDate = DateTime.Now;
                        prod.IsActive   = true;
                    }
                    newShopOffer.ShopOffer.TBL_OfferOnProducts = (newShopOffer.OfferonProducts);
                    EF.TBL_ShopOffers.Add(newShopOffer.ShopOffer);
                    EF.SaveChanges();
                }

                var result = new BSEntityFramework_ResultType(BSResult.Success, newShopOffer.ShopOffer, null, "Created Sucessfully");
                return(result);
            }
            catch (DbEntityValidationException dbValidationEx)
            {
                return(FormatException(dbValidationEx, newShopOffer));
            }
            catch (Exception ex)
            {
                var logact = new LoggerActivity();
                var result = new BSEntityFramework_ResultType(BSResult.Fail, newShopOffer, null, "Technical issue");
                logact.ErrorSetup("WebApp", "InsertShopOffer Failed", "", "", "", ex.Message);
                return(result);
            }
        }
コード例 #28
0
 public BSEntityFramework_ResultType UpdateProductType(TBL_ProductType_CNFG ProductType)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             EF.TBL_ProductType_CNFG.AddOrUpdate(ProductType);
             EF.SaveChanges();
             var result = new BSEntityFramework_ResultType(BSResult.Success, ProductType, null, "Updated Successfully");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, ProductType));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, ProductType, null, "Technical issue");
         logact.ErrorSetup("WebApp", "UpdateProductType Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #29
0
 public BSEntityFramework_ResultType GetPostalCodesCNFG(string hint)
 {
     try
     {
         using (BSDBEntities EF = new BSDBEntities())
         {
             var PostalCodesCNFG =
                 EF.TBL_PostalCodes_CNFG.Where(p => p.PostCodeID.ToString().StartsWith(hint))
                 .Join(EF.TBL_Cities_CNFG, p => p.CityID, c => c.CityID, (p, c) => new
             {
                 PostalCodeId = p.PostCodeID,
                 CityName     = c.CityName,
                 StateID      = c.StateID
             }
                       ).Join(EF.TBL_States_CNFG, R => R.StateID, s => s.StateID, (R, s) => new
             {
                 PostalCodeId = R.PostalCodeId
                 , CityName   = R.CityName,
                 StateName    = s.StateName
             }).ToArray();
             var result = new BSEntityFramework_ResultType(BSResult.FailForValidation, PostalCodesCNFG, null, "Success");
             return(result);
         }
     }
     catch (DbEntityValidationException dbValidationEx)
     {
         return(FormatException(dbValidationEx, null));
     }
     catch (Exception ex)
     {
         var logact = new LoggerActivity();
         var result = new BSEntityFramework_ResultType(BSResult.Fail, null, null, "Technical issue");
         logact.ErrorSetup("WebApp", "GetPostalCodesCNFG Failed", "", "", "", ex.Message);
         return(result);
     }
 }
コード例 #30
0
        public BSEntityFramework_ResultType GetShopOfferListView(int shopId, string sortColumnName, string sortOrder, int pageSize, int currentPage,
                                                                 string offerShortDetails = "",
                                                                 DateTime?offerStartDate  = null,
                                                                 DateTime?offerEndDate    = null,
                                                                 string offerOnBrand      = "",
                                                                 bool?isOfferOnProduct    = null,
                                                                 bool?isActive            = null
                                                                 )
        {
            var List        = new object();
            int totalPage   = 0;
            int totalRecord = 0;

            using (BSDBEntities EF = new BSDBEntities())
            {
                var offers =
                    EF.TBL_ShopOffers.Where(shopoffer => shopoffer.ShopID == shopId &&
                                            (offerShortDetails == null || offerShortDetails.Trim() == "" || shopoffer.OfferShortText.Contains(offerShortDetails)) &&
                                            (offerStartDate == null || offerStartDate == DateTime.MinValue || shopoffer.OfferStartDate.Equals(offerStartDate)) &&
                                            (offerEndDate == null || offerEndDate == DateTime.MinValue || shopoffer.OfferEndDate.Equals(offerEndDate)) &&
                                            (offerOnBrand == null || offerOnBrand.Trim() == "" || shopoffer.OfferOnBrand == offerOnBrand) &&
                                            (isOfferOnProduct == null || isOfferOnProduct == shopoffer.IsOfferOnProducts) &&
                                            (isActive == null || isActive == shopoffer.IsActive)
                                            );

                var offlistBS = offers.Join(EF.TBL_ShopLoginDetails, off => off.CreatedBy
                                            , CrdUser => CrdUser.ShopLoginDetailsID
                                            , (off, CrdUser) => new {
                    // .Select(off => new {
                    off.OfferShortText,
                    off.OfferStartDate,
                    off.OfferEndDate,
                    off.ShopID,
                    off.OfferID,
                    off.IsActive,
                    off.OfferOnBrand,
                    off.OfferDetailText,
                    off.IsOfferOnProducts,
                    off.CreateDate,
                    CreatedBy = CrdUser.LoginName,
                    off.UpdateDate,
                    off.UpdatedBy
                }).GroupJoin(EF.TBL_ShopLoginDetails
                             , off => off.UpdatedBy
                             , updtUser => updtUser.ShopLoginDetailsID
                             , (offersinfo, updateuserDetails) => new {
                    offersinfo        = offersinfo,
                    updateuserDetails = updateuserDetails
                })
                                .SelectMany(
                    Gj => Gj.updateuserDetails.DefaultIfEmpty(),
                    (off, updtUser) => new {
                    offersinfo        = off,
                    updateuserDetails = updtUser
                })
                                .Select(ofd => new {
                    ofd.offersinfo.offersinfo.OfferShortText,
                    ofd.offersinfo.offersinfo.OfferStartDate,
                    ofd.offersinfo.offersinfo.OfferEndDate,
                    ofd.offersinfo.offersinfo.ShopID,
                    ofd.offersinfo.offersinfo.OfferID,
                    ofd.offersinfo.offersinfo.IsActive,
                    ofd.offersinfo.offersinfo.OfferOnBrand,
                    ofd.offersinfo.offersinfo.OfferDetailText,
                    ofd.offersinfo.offersinfo.IsOfferOnProducts,
                    ofd.offersinfo.offersinfo.CreateDate,
                    ofd.offersinfo.offersinfo.CreatedBy,
                    ofd.offersinfo.offersinfo.UpdateDate,
                    UpdatedBy = ofd.updateuserDetails.LoginName
                })
                                .ToArray();


                totalRecord    = offlistBS.Length;
                sortColumnName = sortColumnName ?? "OfferID";
                if (pageSize > 0)
                {
                    totalPage = totalRecord / pageSize + ((totalRecord % pageSize) > 0 ? 1 : 0);
                    List      = offlistBS
                                .OrderBy(sortColumnName + " " + sortOrder)
                                .Skip(pageSize * (currentPage - 1))
                                .Take(pageSize).ToArray();
                }
                else
                {
                    var prodList = offlistBS.ToArray();
                    List = prodList;
                }
            }

            var jsonresult = new JsonResult
            {
                Data = new { List = List, totalPage = totalPage, sortColumnName = sortColumnName, sortOrder = sortOrder, currentPage = currentPage },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            var result = new BSEntityFramework_ResultType(BSResult.Success, List, null, "Fetched Successfully");

            return(result);
        }