public ActionResult Payment() { List <ShopCartItem> cart = Session["ShoppingCart"] as List <ShopCartItem>; if (cart.Count == 0) { ViewBag.Error = "سبد خرید شما خالی است."; return(RedirectToAction("Index")); } var order = _repoOr.AddOrder(cart, int.Parse(User.Identity.Name)); ServicePointManager.Expect100Continue = false; PaymentGatewayImplementationServicePortTypeClient zp = new PaymentGatewayImplementationServicePortTypeClient(); string Authority; int Status = zp.PaymentRequest("YOUR-ZARINPAL-MERCHANT-CODE", order.TotalPrice, "درگاه پرداخت تست زرین پال", "*****@*****.**", "09361997137", "http://localhost:13327/ShoppingCart/Verify/" + order.Id, out Authority); if (Status == 100) { Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority); } else { ViewBag.Error = Status; } return(View()); }
public Order AddOrder(Order order) { var taxInformation = _taxRepo.LoadTaxInformation(order.State); var productInformation = _prodRepo.LoadProduct(order.ProductType); CalculateOrder(order); order.Date = order.Date; _orderRepository.AddOrder(order); return(order); }
public OrderModel CalculateOrder(int customerId, List <int> productIDs) { var customerInfo = _customerRepo.GetCustomerById(customerId).CTM(); var productInfo = _productRepo.GetProductsByIDs(productIDs).CTMs(); var order = CalculateOrder(productInfo, customerInfo.Discounts, customerId, orderModel => _shippingService.CalculateStuff(customerInfo.Address.ToShipping(), orderModel)); order.Status = Order.Enums.OrderStatus.Calculated; order.OrderId = _orderRepo.AddOrder(order.CTE()); return(order); }
public ActionResult <ResultDTO_AddOrder> AddOrder(OrderToAddDTO order) { try { var result = _orderRepo.AddOrder(order); return(result); } catch (Exception e) { // TODO log(e) Console.WriteLine(e); return(new BadRequestResult()); } }
public ActionResult Create([Bind(Include = "Id,OrderDate,ReceptionDate,ReturnDate,UserId,BookId")] Order order, FormCollection form) { if (ModelState.IsValid) { try { var DDLValue = Int32.Parse(Request.Form["BookId"]); var availability = _bookRepo.Availability(DDLValue); if (availability == "No") { throw new Exception(); } else { order.UserId = User.Identity.GetUserId(); order.OrderDate = System.DateTime.Now.Date; DateTime date = order.OrderDate; order.ReceptionDate = date.AddDays(2); order.ReturnDate = date.AddDays(30); _repo.AddOrder(order); _repo.SaveChanges(); _bookRepo.ChangeAvailability(order.BookId, "No"); _bookRepo.SaveChanges(); } } catch { ViewBag.Error = true; return(RedirectToAction("Create", new { error = true })); } //ViewBag.Error = false; ViewBag.BookId = new SelectList(_context.Book, "Id", "Title", order.BookId); } return(RedirectToAction("MyOrder")); }
public void AddOrder(Orders order) { orderRepo.AddOrder(order); }
public Order AddOrder(Order newOrder) { return(_orderRepoDB.AddOrder(newOrder)); }
public PlaceNewOrderResponse NewOrder(DateTime DateInput, string NameInput, string StateInput, string ProductInput, decimal AreaInput) { PlaceNewOrderResponse response = new PlaceNewOrderResponse(); Order orderToAdd = new Order { OrderDate = DateInput, CustomerName = NameInput }; string stateInput = StateInput; string productInput = ProductInput; orderToAdd.Area = AreaInput; bool failState = false; Product product = _productRepo.GetProduct(ProductInput); if (product == null) { response.Message = $"{ProductInput} is not a valid product"; failState = true; } else { orderToAdd.ProductType = product.ProductType; orderToAdd.CostPerSquareFoot = product.CostPerSquareFoot; orderToAdd.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot; } Tax taxInfo = null; if (!failState) { taxInfo = _taxRepo.GetState(StateInput); if (taxInfo == null) { response.Message = $"{StateInput} is not a valid state"; failState = true; } else { orderToAdd.State = taxInfo.StateAbbreviation; orderToAdd.TaxRate = taxInfo.TaxRate; } } if (!failState) { orderToAdd.CostPerSquareFoot = product.CostPerSquareFoot; orderToAdd.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot; orderToAdd.TaxRate = taxInfo.TaxRate; } if (!failState) { orderToAdd.MaterialCost = orderToAdd.Area * orderToAdd.CostPerSquareFoot; orderToAdd.LaborCost = orderToAdd.Area * orderToAdd.LaborCostPerSquareFoot; orderToAdd.TotalTax = (orderToAdd.MaterialCost + orderToAdd.LaborCost) * (orderToAdd.TaxRate / 100); orderToAdd.Total = orderToAdd.MaterialCost + orderToAdd.LaborCost + orderToAdd.TotalTax; } if (!failState) { response.Order = _orderRepo.AddOrder(orderToAdd); } if (failState) { response.Success = false; } else if (response.Order == null) { response.Success = false; response.Message = "An error occurred while submitting the order"; } else { response.Success = true; } return(response); }
public void AddOrder(Order o) { //allows the customer to make an order -> send it to db repo.AddOrder(o); }
public void AddOrder(Order order) { repo.AddOrder(order); }
public bool PostOrder(OrderPlaces orderPlace) { orderRepo.AddOrder(orderPlace); return(true); }
public void AddOrder(Orders newOrder) { repo.AddOrder(newOrder); }