public ActionResult Create(OrderModel order) { if (ModelState.IsValid) { _IOrder.AddOrder(order); return(RedirectToAction("Index")); } ViewBag.ProductTypeID = new SelectList(db.ProductTypes, "TypeName", "TypeName"); return(View(order)); }
public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } StorageModel = _storage.GetWhiskyById(id); if (StorageModel != null) { if (StorageModel.Available > 0) { StorageModel.Available--; StorageModel.Reserved++; _storage.UpdateWhiskyByModel(StorageModel); OrderModel orderModel = new OrderModel(); orderModel.Completed = false; orderModel.Customer = _user.GetUserByName(User.Identity.Name); orderModel.Whisky = StorageModel.Whisky; _order.AddOrder(orderModel); } } return(RedirectToPage("./Index")); }
public IActionResult CreateOrder(string CartId) { //var cartId = model.ShoppingCart.ShoppingCartId; var cartElements = _order.GetShoppingCartItemsToOrder(CartId); Order order = new Order() { OrderNumber = _order.NextNumber(), OrderedDate = DateTime.Now, Status = "Utworzono" }; _order.AddOrder(order); //int OrderId = _order.GetLastId(); foreach (var item in cartElements) { OrderLine orderLine = new OrderLine() { Amount = item.Amount, Price = item.product.Price, Note = item.Note, Product = item.product, Order = order }; _order.AddLine(orderLine); } _order.CalculateOrderTotalPrice(order.Id); return(RedirectToAction("FulfillAddress", "Address", new { OrderId = order.Id })); //return RedirectToAction("FulfillAddress", "Address"); }
public IActionResult BuyProduct(int productId, int sizeId, int colorId, int quantityNumber) { string userNumber = User.FindFirst(ClaimTypes.Email)?.Value; _orderService.AddOrder(productId, userNumber, sizeId, colorId, quantityNumber); Sms.SendSms("09372796350", "افزودن به سبد خرید ." + userNumber); return(Redirect("/UserPanel")); }
public IActionResult CreateOrder(Order order) { order.Lines = GetCart().Selections.Select(s => new OrderLine { ProductId = s.ProductId, Quantity = s.Quantity }).ToArray(); _orderService.AddOrder(order); SaveCart(new Cart()); return(RedirectToAction(nameof(Completed))); }
public HttpResponseMessage AddAnOrder([FromBody] Order_DataAccessLayer.Model.Order order) { Order_DataAccessLayer.Model.Order addAnOrder = new Order_DataAccessLayer.Model.Order() { Amount = order.Amount, VAT = order.VAT, CustomerId = order.CustomerId // can be extracted from a seesion variable of a logged in user }; _order.AddOrder(addAnOrder); return(new HttpResponseMessage(HttpStatusCode.Created)); }
public IActionResult AddOrUpdateOrder(Order order) { order.Lines = order.Lines .Where(l => l.Id > 0 || (l.Id == 0 && l.Quantity > 0)).ToArray(); if (order.Id == 0) { _orderService.AddOrder(order); } else { _orderService.UpdateOrder(order); } return(RedirectToAction(nameof(Index))); }
public IActionResult NewOrder(OrderModel model) { if (!ModelState.IsValid) { ViewData["cart"] = cart.ItemList; return(View(new OrderModel())); } model.Products = new List <ProductStringified>(cart.ItemList.Select(x => new ProductStringified { ProductName = x.Product.Name, ProductQuantity = x.Quantity })); orderManager.AddOrder(model); cart.Clear(); return(Redirect("/Order/Thanks")); }
public async Task AddOrder(Badge badge) { var Order = new Order(); var OrderDtl = new OrderDetails(); var sugar = new Sugar(drinkOrder.Quantity); Order.Badge = badge; await order.AddOrder(Order); OrderDtl.Drink = await drinks.GetDrinkById(drinkOrder.DrinkId); OrderDtl.Mug = drinkOrder.Mug; sugar.Add(OrderDtl); await orderDetail.Add(OrderDtl, Order.Badge.Id); }
public AddOrderResponse addOrder(Order order, DateTime orderDate) { AddOrderResponse response = new AddOrderResponse(); response.order = _orderRepo.AddOrder(order, orderDate); if (response.order == null) { response.Success = false; response.Message = "Order cannot be added. Please try again"; return(response); } else { response.Success = true; } return(response); }
public void AddOrder_ShouldFail() { // Arrange int orderId = 21; int customerId = 6; var amount = 50; decimal vat = new decimal(0.15); var orderDTO = new Order_DataAccessLayer.Model.Order { OrderId = orderId, Amount = amount, CustomerId = customerId, VAT = vat }; _orderMock.Setup(x => x.AddOrder(orderDTO)).Verifiable(); // Act Order_DataAccessLayer.Model.Order result = _orderContext.AddOrder(orderDTO); // Assert Assert.Equal(expected: result, orderDTO); }
public IActionResult AddOrder(AddNewOrderModel addNewOrderModel) { try { if (ModelState.IsValid) { var uniquePONumber = iOrder.GetAllUniquePoNumber(); var uniqueOrderIds = iOrder.GetAllUniqueInvoiceIds(); long promoCodeId = 0; decimal percentage = 0; decimal discountAmount = 0; if (!string.IsNullOrWhiteSpace(addNewOrderModel.Promocode)) { var promocodeModel = iPromoCode.GetPromoCodeByCode(addNewOrderModel.Promocode); if (promocodeModel != null) { promoCodeId = promocodeModel.PromoCodeId; percentage = promocodeModel.Percentage; discountAmount = promocodeModel.Amount; } } Order orderModel = OrderHelper.BindOrderModel(addNewOrderModel, uniquePONumber, uniqueOrderIds, promoCodeId, percentage, discountAmount); List <OrderDetail> detailModel = OrderHelper.BindOrderDetailModel(addNewOrderModel.ProductDetail); long orderId = 0; if (orderModel.OrderId <= 0) { orderId = iOrder.AddOrder(orderModel, detailModel); } else { orderId = iOrder.EditOrder(orderModel, detailModel); } if (orderId > 0) { var cart = iCart.EmptyCart(DBHelper.ParseInt64(addNewOrderModel.UserId)); var orderDetailModel = iOrder.GetOrderDetail(orderId); if (!string.IsNullOrWhiteSpace(addNewOrderModel.IsMailSend) && addNewOrderModel.IsMailSend.Equals("1")) { if (orderDetailModel != null) { var HostingPath = env.ContentRootPath; string clientEmail = config.GetValue <string>("app_settings:ClientEmail"); string clientEmailPassword = config.GetValue <string>("app_settings:ClientEmailPassword"); string port = config.GetValue <string>("app_settings:Port"); string mailHost = config.GetValue <string>("app_settings:SMTPURL"); string host = this.Request.Host.Value; string scheme = this.Request.Scheme; OrderDetailModel orderDetailmodel = OrderHelper.BindOrderDetailModel(orderDetailModel, null); OrderHelper.SendResetPasswordMail(orderDetailmodel.EmailId, orderDetailmodel, DBHelper.ParseString(HostingPath), clientEmail, clientEmailPassword, port, mailHost, host, scheme); } } return(Ok(ResponseHelper.Success(MessageConstants.OrderPlaced + orderDetailModel[0].Order.UniqueOrderId))); } else { return(Ok(ResponseHelper.Error(MessageConstants.OrderNotPlaced))); } } else { return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData))); } } catch (Exception ex) { LogHelper.ExceptionLog(ex.Message + " ::::: " + ex.StackTrace); return(Ok(ResponseHelper.Error(ex.Message))); } }
public static int AddOrder(OrderInfo order) { order.ID = dal.AddOrder(order); return(order.ID); }
public async Task Post([FromBody] Order order) { await orders.AddOrder(order); }
public ActionResult <TOrder> Post(TOrder order) { _order.AddOrder(order); return(Ok()); }
public string AddOrder(int Klantid, int Verkoperid, int Productid, int quantity) { return(context.AddOrder(Klantid, Verkoperid, Productid, quantity)); }
public IActionResult AddOrder(Models.Order customerorder) { int orderid = _userrepo.AddOrder(customerorder); return(Ok(orderid)); }