Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
        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);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
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);
     }
 }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
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);
            }
        }