public static bool Create(ProductModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var newProduct = new DbEntity.product(); newProduct.brandid = obj.BrandId; newProduct.catid = obj.CatId; newProduct.discription = obj.Discription; newProduct.image = obj.Image; newProduct.name = obj.Name; //newProduct.productCode = +obj.Name.Replace(" ", "-"); newProduct.keyWord = obj.KeyWord; newProduct.isHot = obj.Ishot; context.products.Add(newProduct); context.SaveChanges(); foreach (var x in obj.ColorList) { var productPricing = new ProductPriceModel(); productPricing.ProductId = newProduct.id; productPricing.lengthId = x.LengthId; productPricing.colorId = x.id; productPricing.ourpriceangola = x.ourpriceangola; productPricing.OurPriceDollar = x.OurPriceDollar; productPricing.OurPriceEuro = x.OurPriceEuro; productPricing.ourpriceghana = x.ourpriceghana; productPricing.ourpricenigeria = x.ourpricenigeria; productPricing.OurPricePound = x.OurPricePound; productPricing.priceangola = x.priceangola; productPricing.PriceDollar = x.PriceDollar; productPricing.PriceEuro = x.PriceEuro; productPricing.priceghana = x.priceghana; productPricing.pricenigeria = x.pricenigeria; productPricing.PricePound = x.PricePound; check = ProductPricingDal.Create(productPricing); } } catch (Exception ex) { check = false; } return check; }
public static bool Create(ProductPriceModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); context.productpricings.Add( new DbEntity.productpricing { ourpriceangola = obj.ourpriceangola, ourpriceDollar = obj.OurPriceDollar, ourpriceeuro = obj.OurPriceEuro, ourpriceghana = obj.ourpriceghana, ourpricenigeria = obj.ourpricenigeria, ourpricepound = obj.OurPricePound, priceangola = obj.priceangola, priceDollar = obj.PriceDollar, priceeuro = obj.PriceEuro, priceghana = obj.priceghana, pricenigeria = obj.pricenigeria, pricepound = obj.PricePound, productid = obj.ProductId, lengthId = obj.lengthId, colorId = obj.colorId }); context.SaveChanges(); } catch (Exception ex) { check = false; } return check; }
public static CartModel AddItemTocart(int productPriceId, CartModel obj, string Currency, int? quantity, int? deliverId) { bool check = true; decimal total = 0; decimal MinFreeDeliverammount = 0; if (obj == null) { obj = new CartModel(); obj.Product = new List<ProductModel>(); } if (obj.Product == null) { obj.Product = new List<ProductModel>(); } if (quantity.HasValue) { for (int i = 0; i < obj.Product.Count; i++) { if (obj.Product[i].Price.Id == productPriceId) { obj.Product[i].Price.Quantity = Convert.ToInt32(quantity); check = false; } } } var context = new Ecommerce.DbEntity.ecommerceEntities(); var productPrice = new ProductPriceModel(); productPrice = ProductPricingDal.GetPriceByProductPriceId(productPriceId, Currency); var product = new ProductModel(); product = ProductDal.GetById(productPrice.ProductId); product.Price = productPrice; if (check) { if (quantity.HasValue) { product.Price.Quantity = Convert.ToInt32(quantity); } obj.Product.Add(product); } var deliveryCharges = new DeliveryModel(); if (deliverId > 0) { deliveryCharges = DeliveryDal.GetById(Convert.ToInt32(deliverId)); } else { if (obj.DelivierId == 0) { deliveryCharges = DeliveryDal.GetDefault(); } else { deliveryCharges = DeliveryDal.GetById(Convert.ToInt32(obj.DelivierId)); } } obj.DelivierDays = deliveryCharges.DeliveryDays; obj.DelivierId = deliveryCharges.id; if (Currency == "Dollar") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryDoller; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountDoller; } else if (Currency == "Pound") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryPound; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountPound; } else if (Currency == "Euro") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryEuro; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountEuro; } else if (Currency == "Naira") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryNigria; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountNigria; } else if (Currency == "Kwanza") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryAngola; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountAngola; } else if (Currency == "Cedi") { obj.DelivierCharges = (decimal)deliveryCharges.deliveryGhana; MinFreeDeliverammount = (decimal)deliveryCharges.freeDeliveryAmountGhana; } for (int i = 0; i < obj.Product.Count; i++) { decimal _total = Convert.ToDecimal(obj.Product[i].Price.Ourprice) * obj.Product[i].Price.Quantity; obj.Product[i].Price.TotalPrice = obj.Product[i].Price.Ourprice * obj.Product[i].Price.Quantity; total = total + _total; obj.Product[i].CountId = i; } obj.Difference = MinFreeDeliverammount - total; if (obj.Difference <= 0) { obj.Difference = 0; } obj.SubTotalTotal = total; obj.Total = total + obj.DelivierCharges; var validate = CoupanDal.ValidateCoupan(Convert.ToString(obj.DiscountCoupan)); if (validate != null) { obj.DiscountCoupan = obj.DiscountCoupan; obj.DiscountAmmount = (validate.DiscountPercentage / obj.SubTotalTotal) * 100; obj.Total = obj.Total - obj.DiscountAmmount; obj.Total = Math.Round(obj.Total, 2); obj.DiscountAmmount = Math.Round(obj.DiscountAmmount, 2); } obj.AllProductPrice=0; foreach (var x in obj.Product) { obj.AllProductPrice = obj.AllProductPrice + x.Price.TotalPrice; } return obj; }
public static bool Update(ProductModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var Product = context.products.Where(m => m.id == obj.Id).FirstOrDefault(); Product.brandid = obj.BrandId; Product.catid = obj.CatId; Product.discription = obj.Discription; Product.image = obj.Image; Product.name = obj.Name; Product.keyWord = obj.KeyWord; Product.isHot = obj.Ishot; context.SaveChanges(); ProductPricingDal.Delete(obj.Id); foreach (var x in obj.ColorList) { var productPricing = new ProductPriceModel(); productPricing.ProductId = Product.id; productPricing.lengthId = x.LengthId; productPricing.colorId = x.id; productPricing.ourpriceangola = x.ourpriceangola; productPricing.OurPriceDollar = x.OurPriceDollar; productPricing.OurPriceEuro = x.OurPriceEuro; productPricing.ourpriceghana = x.ourpriceghana; productPricing.ourpricenigeria = x.ourpricenigeria; productPricing.OurPricePound = x.OurPricePound; productPricing.priceangola = x.priceangola; productPricing.PriceDollar = x.PriceDollar; productPricing.PriceEuro = x.PriceEuro; productPricing.priceghana = x.priceghana; productPricing.pricenigeria = x.pricenigeria; productPricing.PricePound = x.PricePound; check = ProductPricingDal.Create(productPricing); } } catch (Exception ex) { check = false; } return check; }
public static List<ProductPriceModel> GetAllByProductId(int productId) { List<ProductPriceModel> listobj = new List<ProductPriceModel>(); var context = new Ecommerce.DbEntity.ecommerceEntities(); var productPricinglist = context.productpricings.Where(m => m.productid == productId).ToList(); foreach (var productPricing in productPricinglist) { ProductPriceModel obj = new ProductPriceModel(); obj.ourpriceangola = Convert.ToDecimal(productPricing.ourpriceangola); obj.OurPriceDollar = Convert.ToDecimal(productPricing.ourpriceDollar); obj.OurPriceEuro = Convert.ToDecimal(productPricing.ourpriceeuro); obj.ourpriceghana = Convert.ToDecimal(productPricing.ourpriceghana); obj.ourpricenigeria = Convert.ToDecimal(productPricing.ourpricenigeria); obj.OurPricePound = Convert.ToDecimal(productPricing.ourpricepound); obj.priceangola = Convert.ToDecimal(productPricing.priceangola); obj.PriceDollar = Convert.ToDecimal(productPricing.priceDollar); obj.PriceEuro = Convert.ToDecimal(productPricing.priceeuro); obj.priceghana = Convert.ToDecimal(productPricing.priceghana); obj.pricenigeria = Convert.ToDecimal(productPricing.pricenigeria); obj.PricePound = Convert.ToDecimal(productPricing.pricepound); obj.ProductId = Convert.ToInt32(productPricing.productid); obj.ColorName = ColorDal.GetById(Convert.ToInt32(productPricing.colorId)).name; obj.LengthName = LengthDal.GetById(Convert.ToInt32(productPricing.lengthId)).value; obj.colorId = Convert.ToInt32(productPricing.colorId); obj.lengthId = Convert.ToInt32(productPricing.lengthId); obj.Id = Convert.ToInt32(productPricing.id); listobj.Add(obj); } return listobj; }
public static bool Update(ProductPriceModel obj) { bool check = true; try { var context = new Ecommerce.DbEntity.ecommerceEntities(); var cat = context.productpricings.Where(m => m.id == obj.Id).FirstOrDefault(); cat.ourpriceangola = obj.ourpriceangola; cat.ourpriceDollar = obj.OurPriceDollar; cat.ourpriceeuro = obj.OurPriceEuro; cat.ourpriceghana = obj.ourpriceghana; cat.ourpricenigeria = obj.ourpricenigeria; cat.ourpricepound = obj.OurPricePound; cat.priceangola = obj.priceangola; cat.priceDollar = obj.PriceDollar; cat.priceeuro = obj.PriceEuro; cat.priceghana = obj.priceghana; cat.pricenigeria = obj.pricenigeria; cat.pricepound = obj.PricePound; context.SaveChanges(); } catch (Exception ex) { check = false; } return check; }
public static ProductPriceModel GetPriceByProductPriceId(int producPriceId, string Currency) { ProductPriceModel obj = new ProductPriceModel(); var context = new Ecommerce.DbEntity.ecommerceEntities(); var ProductPrice = context.productpricings.Where(m => m.id == producPriceId).FirstOrDefault(); if (ProductPrice != null) { obj.Id = ProductPrice.id; obj.ProductId = Convert.ToInt32(ProductPrice.productid); obj.LengthName=LengthDal.GetById(Convert.ToInt32(ProductPrice.lengthId)).value; obj.ColorName = ColorDal.GetById(Convert.ToInt32(ProductPrice.colorId)).name; if (Currency == "Dollar") { obj.Unitprice = Convert.ToDecimal(ProductPrice.ourpriceDollar); obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceDollar); obj.Actualprice = Convert.ToDecimal(ProductPrice.priceDollar); } else if (Currency == "Euro") { obj.Unitprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Actualprice = Convert.ToDecimal(ProductPrice.priceeuro); } if (Currency == "Pound") { obj.Unitprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Actualprice = Convert.ToDecimal(ProductPrice.pricepound); } else if (Currency == "Naira") { obj.Unitprice = Convert.ToDecimal(ProductPrice.ourpricenigeria); obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpricenigeria); obj.Actualprice = Convert.ToDecimal(ProductPrice.pricenigeria); } if (Currency == "Kwanza") { obj.Unitprice = Convert.ToDecimal(ProductPrice.priceangola); obj.Ourprice = Convert.ToDecimal(ProductPrice.priceangola); obj.Actualprice = Convert.ToDecimal(ProductPrice.ourpriceangola); } else if (Currency == "Cedi") { obj.Unitprice = Convert.ToDecimal(ProductPrice.priceghana); obj.Ourprice = Convert.ToDecimal(ProductPrice.priceghana); obj.Actualprice = Convert.ToDecimal(ProductPrice.ourpriceghana); } } return obj; }
public static ProductPriceModel GetPriceByProductandLengthandColor(int productId, int LengthId, int colorId, string Currency) { ProductPriceModel obj = new ProductPriceModel(); var context = new Ecommerce.DbEntity.ecommerceEntities(); var ProductPrice = context.productpricings.Where(m => m.productid == productId && m.colorId == colorId && m.lengthId == LengthId).FirstOrDefault(); if (ProductPrice != null) { obj.Id = ProductPrice.id; if (Currency == "Dollar") { obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceDollar); obj.Actualprice = Convert.ToDecimal(ProductPrice.priceDollar); } else if (Currency == "Euro") { obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Actualprice = Convert.ToDecimal(ProductPrice.priceeuro); } if (Currency == "Pound") { obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpriceeuro); obj.Actualprice = Convert.ToDecimal(ProductPrice.pricepound); } else if (Currency == "Naira") { obj.Ourprice = Convert.ToDecimal(ProductPrice.ourpricenigeria); obj.Actualprice = Convert.ToDecimal(ProductPrice.pricenigeria); } if (Currency == "Kwanza") { obj.Ourprice = Convert.ToDecimal(ProductPrice.priceangola); obj.Actualprice = Convert.ToDecimal(ProductPrice.ourpriceangola); } else if (Currency == "Cedi") { obj.Ourprice = Convert.ToDecimal(ProductPrice.priceghana); obj.Actualprice = Convert.ToDecimal(ProductPrice.ourpriceghana); } } return obj; }
public ActionResult Ordersummery() { CartModel obj = new CartModel(); obj.Product = new List<ProductModel>(); var order = new OrderHeader(); order.OrderDetail = new List<OrderDetail>(); if (Session["OrderId"] != null) { order = OrderDal.GetByOrderId((int)Session["OrderId"]); } obj.Total = order.AmountInCurrencyChoosenByuser; obj.DelivierCharges = order.DeliveryCharges; foreach (var x in order.OrderDetail) { var productPrice = new ProductPriceModel(); productPrice = ProductPricingDal.GetPriceByProductPriceId(x.ProductPriceId, Convert.ToString(Session["currency"])); var product = new ProductModel(); product = ProductDal.GetById(productPrice.ProductId); var productModel = new ProductModel(); productModel.Image = product.Image; productModel.Name = product.Name; productModel.Price = new ProductPriceModel(); productModel.Price.Ourprice = x.ActualPriceInUserSeletedCurrency; productModel.Price.Quantity = x.Quantity; productModel.Price.LengthName = productPrice.LengthName; productModel.Price.ColorName = productPrice.ColorName; obj.Product.Add(productModel); } return PartialView(obj); }