public async Task <ActionResult> DelProducts(int id) { Session["ChProducts"] = id; OrderProductView products = await db.OrderProductViews.FindAsync(id); return(View(products)); }
public void TestGetSelectedProduct() { ProductLogic logic = new ProductLogic(); try { logic.Create(new ProductBinding { Name = "Test1", Price = 10 }); OrderProductView orderProduct = new OrderProductView { ProductId = 1 }; OrderProductPageDriver driver = new OrderProductPageDriver(new UiContext(new OrderLogic(), logic), new OrderView(), orderProduct); ProductView product1 = driver.GetSelectedProduct(); driver = new OrderProductPageDriver(new UiContext(new OrderLogic(), logic), new OrderView(), null); ProductView product2 = driver.GetSelectedProduct(); Assert.Equal("Test1", product1.Name); Assert.Equal(10, product1.Price); Assert.Null(product2); } finally { logic.Delete(null); } }
public OrderProductPageDriver(UiContext context, OrderView order, OrderProductView orderProduct) : base(context) { this.order = order; this.orderProduct = orderProduct ?? new OrderProductView { Id = -1 }; }
public FormOrderProduct(UiContext context, OrderView order, OrderProductView orderProduct) { InitializeComponent(); driver = new OrderProductPageDriver(context, order, orderProduct); ConfigureDriver(); }
public async Task <ActionResult> Products(OrderProductView svd) { orderSes = (OrderSes)Session["OrdSes"]; if (Session["Products"] != null) { await repo.SaveDetail(orderSes.id, svd); } return(RedirectToAction("Booking", "Order", new { id = orderSes.id })); }
public void DeleteOrderProduct() { try { OrderProductView op = SelectedOrderProduct(); order.OrderProducts.Remove(op); } catch (Exception ex) { ShowErrorMessage(ex.Message); } }
public void TestOrderProductView() { OrderProductView opv = new OrderProductView { Id = 0, OrderId = 0, ProductId = 0, ProductName = "Test", Count = 10, Price = 100 }; Assert.Equal(0, opv.Id); Assert.Equal(0, opv.OrderId); Assert.Equal(0, opv.ProductId); Assert.Equal("Test", opv.ProductName); Assert.Equal(10, opv.Count); Assert.Equal(100, opv.Price); }
public static PayUForm GetPayUFrom(OrderDetailsView orderDetails) { PayUForm payUForm = new PayUForm(); payUForm.listProduct = new List <OrderProductView>(orderDetails.orderProductList); OrderProductView ord = new OrderProductView(); ord.ProductName = orderDetails.NameDelivery; ord.ProductPriceB = orderDetails.DeliveryPriceB; ord.QuantityChoose = 1; payUForm.listProduct.Add(ord); Dictionary <string, string> dictionaryPayU = new Dictionary <string, string>(); dictionaryPayU.Add("customerIp", "127.0.0.1"); dictionaryPayU.Add("merchantPosId", "145227"); dictionaryPayU.Add("description", "Sklep internetowy"); String totalPrice = orderDetails.TotalOrderPriceB.Replace(" ", "").Replace("zł", ""); Decimal tPrice = decimal.Parse(totalPrice); tPrice = tPrice * 100; dictionaryPayU.Add("totalAmount", ((int)tPrice).ToString()); dictionaryPayU.Add("currencyCode", "PLN"); dictionaryPayU.Add("notifyUrl", "http://localhost:44300/Home/testPay"); dictionaryPayU.Add("continueUrl", "http://localhost:44300/Zamowienia/PayUSuccess"); // po udanej transakcji for (int i = 0; i < payUForm.listProduct.Count; i++) { dictionaryPayU.Add("products[" + i + "].name", payUForm.listProduct[i].ProductName); String itemPrice = (payUForm.listProduct[i].ProductPriceB).Replace(" ", "").Replace("zł", ""); Decimal itPrice = decimal.Parse(itemPrice); itPrice = itPrice * 100; dictionaryPayU.Add("products[" + i + "].unitPrice", ((int)itPrice).ToString()); dictionaryPayU.Add("products[" + i + "].quantity", payUForm.listProduct[i].QuantityChoose.ToString()); } dictionaryPayU = dictionaryPayU.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); string content = ""; foreach (var item in dictionaryPayU) { content = content + item.Key + "=" + Uri.EscapeDataString(item.Value).Replace("%20", "+") + "&"; } content = content + "13a980d4f851f3d9a1cfc792fb1f5e50"; string hash = sha256(content); dictionaryPayU.Add("Signature", "sender=145227;algorithm=SHA-256;signature=" + hash); payUForm.PayUConfiguration = dictionaryPayU; return(payUForm); }
public static List <OrderProductView> GetOrderProducts(int orderID) { List <OrderProductView> orderProductList = new List <OrderProductView>(); using (sklepEntities db = new sklepEntities()) { var products = db.ProductsOfOrders.Where(x => x.NumOfOrderID == orderID); foreach (ProductsOfOrders item in products) { Products pr = db.Products.Where(x => x.ProductID == item.ProductID).Single(); string ImagePath = db.Images.Where(x => x.ProductID == item.ProductID).Select(x => x.Path).First(); OrderProductView product = new OrderProductView(item.ProductID, pr.Name, item.PriceN.ToString("C2"), ((1 + item.Vat) * item.PriceN).ToString("C2"), ((decimal)(((1M + item.Vat) * item.PriceN) * item.Quantity)).ToString("C2"), (int)item.Quantity, ImagePath); orderProductList.Add(product); } } return(orderProductList); }
public async Task <ActionResult> Products(int id) { Good good = await db.Goods.FindAsync(id); OrderProductView svd = new OrderProductView(); svd.GoodId = good.GoodID; svd.Good = good.txt; svd.Unit = good.Unit; svd.OrderId = id; if (Session["ChProducts"] != null) { int DetId = (int)Session["ChProducts"]; Session["ChProducts"] = null; svd.OrderProductId = DetId; } return(View(svd)); }
public async Task <int> SaveDetail(int id, OrderProductView det) { OrderProduct products = new OrderProduct(); products.OrderProductId = det.OrderProductId; products.GoodId = det.GoodId; products.OrderId = id; products.Quant = det.Quant; if (products.OrderProductId == 0) { db.OrderProducts.Add(products); } else { db.Entry(products).State = EntityState.Modified; } int iddet = await db.SaveChangesAsync(); return(iddet); }
public void TestGetCount() { ProductLogic logic = new ProductLogic(); try { logic.Create(new ProductBinding { Name = "Test1", Price = 10 }); OrderProductView orderProduct = new OrderProductView { ProductId = 1, Count = 10 }; OrderProductPageDriver driver = new OrderProductPageDriver(new UiContext(new OrderLogic(), logic), new OrderView(), orderProduct); int count = driver.GetCount(); Assert.Equal(10, count); } finally { logic.Delete(null); } }
public static SummaryOrderViewModel GetOrderToSummary(DeliveryAddressViewModel deliveryAddressViewModel, int deliveryID, string login, out int status) { using (sklepEntities db = new sklepEntities()) { Deliveries delivery = db.Deliveries.Where(x => x.DeliveryID == deliveryID).Single(); Users user = db.Users.Where(x => x.UserName == login).Single(); int orderID = db.Orders.Where(x => x.UserID == user.UserID) .OrderByDescending(x => x.OrderID) .Select(x => x.OrderID) .First(); Orders order = db.Orders.Where(x => x.OrderID == orderID).Single(); var productsOfOrder = db.ProductsOfOrders.Where(x => x.NumOfOrderID == orderID); order.PriceN = order.PriceN + delivery.PriceN; order.PriceB = order.PriceB + (1M + delivery.Vat) * delivery.PriceN; order.NameDelivery = delivery.Name; order.PriceNDelivery = delivery.PriceN; order.VATDelivery = delivery.Vat; order.DeliverCity = deliveryAddressViewModel.City; order.DeliverNumOfHouse = deliveryAddressViewModel.NumOfHouse; order.DeliverPostCode = deliveryAddressViewModel.PostCode; order.DeliverStreet = deliveryAddressViewModel.Street; order.Name = deliveryAddressViewModel.Name; order.Surname = deliveryAddressViewModel.Surname; SummaryOrderViewModel orderDetails = new SummaryOrderViewModel(); orderDetails.orderProductList = new List <OrderProductView>(); List <ShoppingCartView> productsList = new List <ShoppingCartView>(); foreach (ProductsOfOrders item in productsOfOrder) { OrderProductView orderProductView = new OrderProductView(); orderProductView.ProductID = item.ProductID; orderProductView.ProductName = db.Products.Where(x => x.ProductID == item.ProductID).Select(x => x.Name).Single(); orderProductView.ProductPriceN = item.PriceN.ToString("C2"); orderProductView.ProductPriceB = ((1M + item.Vat) * item.PriceN).ToString("C2"); // ToString("C2") oznacza - ustawienie zapisania ceny w odpowiedni sposob orderProductView.QuantityChoose = (int)item.Quantity; orderProductView.TotalProductPriceB = ((1M + item.Vat) * item.PriceN * (int)item.Quantity).ToString("C2"); var productWithImage = from pro in db.Products // znalezienie zdjec danego produktu w bazie danych where pro.ProductID == item.ProductID join img in db.Images on pro.ProductID equals img.ProductID select new { pro.ProductID, img.Path }; var image = productWithImage.GroupBy(p => p.ProductID).Select(s => s.FirstOrDefault()).Single(); // wybranie pierwszego zdjecia produktu orderProductView.ImagePath = image.Path; orderDetails.orderProductList.Add(orderProductView); } orderDetails.TotalOrderPriceN = ((decimal)order.PriceN).ToString("C2"); orderDetails.TotalOrderPriceB = ((decimal)order.PriceB).ToString("C2"); orderDetails.NameDelivery = delivery.Name; orderDetails.DeliveryPriceB = ((1M + delivery.Vat) * delivery.PriceN).ToString("C2"); orderDetails.Name = order.Name; orderDetails.Surname = order.Surname; orderDetails.Street = order.DeliverStreet; orderDetails.NumOfHouse = order.DeliverNumOfHouse; orderDetails.PostCode = order.DeliverPostCode; orderDetails.City = order.DeliverCity; orderDetails.OrderID = order.OrderID; if (delivery.DeliveryID <= 1) // czy przedplata { order.Status = "Oczekiwanie na wpłatę"; db.SaveChanges(); status = 1; GenereateOrderPdf(orderID); return(orderDetails); } else // czy za pobraniem { order.Status = "Oczekiwanie na wysyłkę"; db.SaveChanges(); status = 0; GenereateOrderPdf(orderID); return(orderDetails); } } }
public ActionResult GoodOrder(int ord) { OrderProductView product = db.OrderProductViews.FirstOrDefault(a => a.OrderId == ord); return(PartialView(product)); }