public async Task TalabatTakeAndSafe(object Json) { try { if (Json != null) { Trace.WriteLine("Json пришёл успешно"); await iOrdersRepository.Create(new PackagedOrder() { OrderNumber = 0, OrderType = "Talabat", JsonOrder = Convert.ToString(Json), ConvertedJsonOrder = null, DateTime = DateTime.Now, }); } else { Trace.WriteLine("Json не пришёл"); } } catch (Exception ERROR) { var loger = new Loger(iLogRepository); await loger.DbExeptionHandler(iLogger, ERROR); await loger.FileExeptionHandler(ERROR); } }
public StatusModel Create(Order order) { var response = new StatusModel(); var booksOrdered = order.Books; decimal fullPrice = 0; foreach (var bookOrder in booksOrdered) { var book = _booksRepository.GetById(bookOrder.BookId); if (book.Quantity < 1) { response.IsSuccessfull = false; response.Message = $"There are no copies of the book {book.Title} currently in stock."; return(response); } else { book.Quantity--; fullPrice += book.Price; continue; } } order.DateCreated = DateTime.Now; order.FullPrice = fullPrice; _ordersRepository.Create(order); response.Message = "The order has been successfully completed"; return(response); }
public bool Create(Order order) { //bookservice.GetBooksByIds() foreach (var book in order.Books) { var bookToCheck = _booksRepository.GetById(book.BookId); if (bookToCheck.Quantity < 1) { return(false); } else { bookToCheck.Quantity -= 1; _booksRepository.Update(bookToCheck); } } order.DateCreated = DateTime.Now; _ordersRepository.Create(order); return(true); }
public CreateOrderResponse Create(CreateOrderDto createOrderDto) { //get by ids var books = booksService.GetByIds(createOrderDto.BookIds); //create new order object var newOrder = new Order { Name = createOrderDto.Name, Address = createOrderDto.Address, Email = createOrderDto.Email, Phone = createOrderDto.Phone, BookOrders = createOrderDto.BookIds.Select(x => new BookOrders { BookId = x }).ToList(), FullPrice = books.Sum(x => x.Price), OrderCode = Helper.RandomString(6) }; //save ordersRepository.Create(newOrder); var response = new CreateOrderResponse(); response.OrderCode = newOrder.OrderCode; return(response); }
public async Task <ActionResult <Order> > Post([FromBody] Order order) { order.Id = await this._ordersrepo.GetNextId(); string jsondata = JsonConvert.SerializeObject(order); await _ordersrepo.Create(order); return(new OkObjectResult(order)); }
public IActionResult MakeChangesInOrder(int id, string status) { Order order = _ordersRepository.Get(id); order.Status = status; _ordersRepository.Delete(order.Id); _ordersRepository.Create(order); return(Redirect("~/Administration/OrderManagement")); }
public ActionResult <Order> Create() { try { return(_ordersRepo.Create()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Create([FromBody] Orders Orders) { // var claims = User.Claims.Select(claim => new { claim.Type, claim.Value }).ToDictionary( t => t.Type, t => t.Value); // if(claims.ContainsKey("name")){ // if( claims["name"].Equals("ADMIN") || claims["name"].Equals("MANAGER") || claims["name"].Equals("PARTNER") ){ Orders.Id = Guid.NewGuid() + ""; Orders.IsDelete = false; return(Ok(_repository.Create(Orders))); // } // }else{ // return Forbid(); // } // return Forbid(); }
public ActionResult <Result <GetOrderDto> > Post([FromBody] CreateOrderDto orderDto) { var orderToPost = orderConverter.FromCreateDto(orderDto); orderToPost.Price = orderPriceCalculator.CalculateOrderPrice(orderDto.Goods); var resultFromRepository = ordersRepository.Create(orderToPost); return(CreatedAtAction(nameof(Get), new { id = resultFromRepository.Value.Id }, new Result <GetOrderDto> { IsSuccess = resultFromRepository.IsSuccess, Message = resultFromRepository.Message, Value = resultFromRepository.Value != null ? orderConverter.ToGetDto(resultFromRepository.Value) : null })); }
public async Task Create(OrderServiceModel order) { var actionItem = await _actionItemRepository.Get(order.ActionItemId); if (actionItem == null) { throw new EntryNotFoundException($"The entry with id '{order.ActionItemId}' was not found"); } var newOrder = new Order() { ActionItem = actionItem, Customer = order.Customer, Tickets = order.Tickets }; _ordersRepository.Create(newOrder); await _ordersRepository.SaveChanges(); }
public virtual async Task <OrderInfo> Execute(OrderBaseInfo orderBaseInfo) { var entryValidation = _validator.Validate(orderBaseInfo); if (!entryValidation.IsValid) { var msgError = ""; foreach (var error in entryValidation.Errors) { msgError += $"{error.ErrorCode}. {error.PropertyName}: {error.ErrorMessage} > {error.CustomState}"; } throw new ArgumentException(msgError); } var orderInfo = _map.Map <OrderInfo>(orderBaseInfo); orderInfo.OrderSituation = EnumOrderSituation.Registered; orderInfo.TotalBrokerFees = orderInfo.OrderItems.Sum(oi => oi.BrokerFees?.Value ?? 0); orderInfo.TotalCompanyFees = orderInfo.OrderItems.Sum(oi => oi.CompanyFees?.Value ?? 0); orderInfo.TotalGrossValue = orderInfo.OrderItems.Sum(oi => oi.GrossValue); orderInfo.TotalNetValue = orderInfo.OrderItems.Sum(oi => oi.NetValue); return((OrderInfo)await _orderRepository.Create(orderInfo)); }
public async Task <ActionResult> Create(Orders newOrder) { await orders.Create(newOrder); return(RedirectToAction("Index")); }
public ActionResult CompleteOrder() { //finalize the order from cart //shopping cart data int Locationid = int.Parse(HttpContext.Request.Cookies["LocationID"]); int customerid = int.Parse(HttpContext.Request.Cookies["CustomerID"]); int ProductID1 = int.Parse(HttpContext.Request.Cookies["ProID1"]); int ProductID2 = int.Parse(HttpContext.Request.Cookies["ProID2"]); int ProductID3 = int.Parse(HttpContext.Request.Cookies["ProID3"]); int ProductID4 = int.Parse(HttpContext.Request.Cookies["ProID4"]); int ProductID5 = int.Parse(HttpContext.Request.Cookies["ProID5"]); int Amount1 = int.Parse(HttpContext.Request.Cookies["PA1"]); int Amount2 = int.Parse(HttpContext.Request.Cookies["PA2"]); int Amount3 = int.Parse(HttpContext.Request.Cookies["PA3"]); int Amount4 = int.Parse(HttpContext.Request.Cookies["PA4"]); int Amount5 = int.Parse(HttpContext.Request.Cookies["PA5"]); //New Order History OrderHistory orderHistory = new OrderHistory { LocationId = Locationid, CustomerId = customerid }; _orderhistoryRepo.Create(orderHistory); //The new Order ID int orderid = _orderhistoryRepo.GetAll().Count(); //note to self, compress next step into dynamic //new orders if (ProductID1 == 1) { Inventory inventory1 = new Inventory { LocationId = Locationid, ProductId = ProductID1, Amount = Amount1 }; Orders orders1 = new Orders { OrderID = orderid, ProductID = ProductID1, Amount = Amount1 }; //finalize _inventoryRepo.Update(inventory1); _ordersRepo.Create(orders1); } if (ProductID2 == 2) { Inventory inventory2 = new Inventory { LocationId = Locationid, ProductId = ProductID2, Amount = Amount2 }; Orders orders2 = new Orders { OrderID = orderid, ProductID = ProductID2, Amount = Amount2 }; //finalize _inventoryRepo.Update(inventory2); _ordersRepo.Create(orders2); } if (ProductID3 == 3) { Inventory inventory3 = new Inventory { LocationId = Locationid, ProductId = ProductID3, Amount = Amount3 }; Orders orders3 = new Orders { OrderID = orderid, ProductID = ProductID3, Amount = Amount3 }; //finalize _inventoryRepo.Update(inventory3); _ordersRepo.Create(orders3); } if (ProductID4 == 4) { Inventory inventory4 = new Inventory { LocationId = Locationid, ProductId = ProductID4, Amount = Amount4 }; Orders orders4 = new Orders { OrderID = orderid, ProductID = ProductID4, Amount = Amount4 }; //finalize _inventoryRepo.Update(inventory4); _ordersRepo.Create(orders4); } if (ProductID5 == 5) { Inventory inventory5 = new Inventory { LocationId = Locationid, ProductId = ProductID5, Amount = Amount5 }; Orders orders5 = new Orders { OrderID = orderid, ProductID = ProductID5, Amount = Amount5 }; //finalize _inventoryRepo.Update(inventory5); _ordersRepo.Create(orders5); } return(RedirectToAction(nameof(Index))); }
public IActionResult Create([FromBody] Orders Orders) { Orders.Id = Guid.NewGuid() + ""; Orders.IsDelete = false; return(Ok(_repository.Create(Orders))); }
public void Create(Order order) { //bookservice.GetBooksByIds() order.DateCreated = DateTime.Now; ordersRepository.Create(order); }
public void Post([FromBody] AddOrderModel order) { _orders.Create(order); }
public async Task <DTO.Order> Execute(Order order) { return(await _OrdersRepository.Create(order)); }
public JsonResult Create() { var order = _ordersRepository.Create(); return(Json(order)); }