public async Task <IActionResult> Update([FromBody] UpdateOrderDto model) { if (model is null) { return(BadRequest(nameof(model))); } var customerId = GetCurrentCustomerId(); var order = await _orderService.GetCustomerOrderByIdAsync(model.Id, customerId); if (order is null) { return(NotFound("Order not found !!!")); } try { // map model to entity order.OrderNote = model.OrderNote; order.OrderStatus = model.OrderStatus; // create order await _orderService.UpdateOrderAsync(order); } catch (Exception ex) { return(Ok("Order not updated.")); } return(Ok("Order updated ✔")); }
public async Task <IActionResult> UpdateOrder([FromBody] UpdateOrderDto data) { var command = new UpdateOrderCommand(data); var result = await _mediator.Send(command); return(result.ErrorMessage == string.Empty ? (IActionResult)Ok() : NotFound(result.ErrorMessage)); }
public string ChangeStatus(UpdateOrderDto updateOrderDto) { string orderStatus = ""; string retStatus = ""; try { var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; var userId = identity.Claims.Where(c => c.Type == ClaimTypes.Sid) .Select(c => c.Value) .SingleOrDefault(); using (ORDR_MGMT_SYSEntities en = new ORDR_MGMT_SYSEntities()) { var updateOrder = en.USR_ORDERS.Where(x => x.ORD_ID == updateOrderDto.ORD_ID && x.ORD_LINE_NUM == updateOrderDto.LINE_NUM).SingleOrDefault(); updateOrder.ORDER_STATUS = updateOrderDto.ORDER_STATUS; updateOrder.LAST_MODIFIED_ON = DateTime.Now; if (orderStatus == "Completed") { updateOrder.RECEIPT_DATE = DateTime.Now; } updateOrder.LAST_MODIFIED_BY = userId; en.SaveChanges(); } retStatus = "Updated Successfully"; } catch (Exception ex) { retStatus = ex.InnerException.Message.ToString(); } return(retStatus); }
public Order UpdateOrderDtoToOrder(UpdateOrderDto updateOrderDto) { return(new Order { OrderDate = updateOrderDto.OrderDate, RentalTime = updateOrderDto.RentalTime, DeliveryPlace = updateOrderDto.DeliveryPlace }); }
public async Task <OrderDto> UpdateOrder(string orderNumber, UpdateOrderDto updateOrderDto) { var foundOrderEntity = await this.parkingLotDbContext.Orders.FirstOrDefaultAsync(orderEntity => orderEntity.OrderNumber == orderNumber); if (foundOrderEntity == null) { return(null); } foundOrderEntity.OrderStatus = updateOrderDto.OrderStatus; return(new OrderDto(foundOrderEntity)); }
public ActionResult <Result <GetOrderDto> > Put([FromBody] UpdateOrderDto orderDto) { var resultFromRepository = ordersRepository.Update(orderConverter.FromUpdateDto(orderDto)); return(new Result <GetOrderDto> { IsSuccess = resultFromRepository.IsSuccess, Message = resultFromRepository.Message, Value = resultFromRepository.Value != null ? orderConverter.ToGetDto(resultFromRepository.Value) : null }); }
public Order FromUpdateDto(UpdateOrderDto updateOrderDto) { return(new Order { Id = updateOrderDto.Id, CreationDate = updateOrderDto.CreationDate, PaymentStatus = updateOrderDto.PaymentStatus, DeliveryStatus = updateOrderDto.DeliveryStatus, Customer = new Customer { Id = updateOrderDto.CustomerId }, Goods = updateOrderDto.Goods.Select(item => FromOrderGoodDto(item)).ToList() }); }
public async Task <bool> UpdateOrder(UpdateOrderDto updateOrderDto) { var order = await _unitOfWork.OrderRepository.FindByIdAsync(updateOrderDto.Id); if (order != null) { var product = await _unitOfWork.ProductRepository.FindByIdAsync(order.ProductId); if (updateOrderDto.OrderQuantity <= product.ProductQuantity && order.DeliveryState == DeliveryState.OrderBooker) { var newOrder = _mapper.Map <UpdateOrderDto, Orders>(updateOrderDto); _unitOfWork.OrderRepository.Update(newOrder); return(await _unitOfWork.SaveAsync() > 0); } } return(false); }
public ActionResult <UpdateOrderDto> ChangeOrder(int signId, UpdateOrderDto targetValue) { var data = dataContext.Set <Order>().FirstOrDefault(x => x.Id == signId); { if (data == null) { return(BadRequest()); } data.Id = targetValue.Id; data.purchaseTime = targetValue.purchaseTime; data.email = targetValue.email; data.address = targetValue.address; data.signs = targetValue.signs; }; dataContext.SaveChanges(); return(Ok()); }
public async Task <IActionResult> PutAsync(Guid id, UpdateOrderDto updateItemDto) { var existingOrder = await repository.GetAsync(id); if (existingOrder == null) { return(NotFound()); } existingOrder.Address = updateItemDto.Address; existingOrder.Quantity = updateItemDto.Quantity; await repository.UpdateAsync(existingOrder); //await publishEndpoint.Publish(new CatalogItemUpdated(existingItem.Id, existingItem.Name, existingItem.Description)); return(NoContent()); }
public ActionResult UpdateOrder(Guid id, UpdateOrderDto OrderDto) { var existingOrder = repository.GetOrder(id); if (existingOrder is null) { return(NotFound()); } Order updatedOrder = existingOrder with { Customer = OrderDto.Customer, OrderDesc = OrderDto.OrderDesc, OrderSku = OrderDto.OrderSku }; repository.UpdateOrder(updatedOrder); return(NoContent()); }
public async Task Should_update_order_status_to_close_when_car_left_via_service() { var scope = Factory.Services.CreateScope(); var scopedServices = scope.ServiceProvider; ParkingLotDbContext context = scopedServices.GetRequiredService <ParkingLotDbContext>(); context.Orders.RemoveRange(context.Orders); context.SaveChanges(); ParkingLotService parkingLotService = new ParkingLotService(context); OrderService orderService = new OrderService(context); parkingLotService.AddParkingLot(parkingLotDto1); UpdateOrderDto updateOrderDto = new UpdateOrderDto("closed"); var addOrderNumber = await orderService.AddOrder(orderDto1); var orderDto = await orderService.UpdateOrder(addOrderNumber, updateOrderDto); Assert.Equal("closed", orderDto.OrderStatus); }
public async Task <IActionResult> UpdateOrder(UpdateOrderDto updateOrderDto) { try { if (updateOrderDto != null) { var result = await _orderService.UpdateOrder(updateOrderDto); if (result) { return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }
public IActionResult Put(int id, [FromBody] UpdateOrderDto model) => _mapper.Map <OrderUpdateModel>(model) .Map(x => _commandRepo.Update(id, x)) .Map(x => AllOk(new { updated = x })) .Reduce(_ => NotFound(), error => error is RecordNotFound) .Reduce(_ => InternalServerError(), x => _logger.LogError(x.ToString()));
public Task <bool> UpdateOrderAsync(UpdateOrderDto OrderDto) { throw new System.NotImplementedException(); }
public UpdateOrderCommand(UpdateOrderDto order) { Order = order; }
/* Update in Db actions */ public GetOrderDto UpdateOrder(int id, UpdateOrderDto updateOrderDto) { var updateOrder = _orderConverter.UpdateOrderDtoToOrder(updateOrderDto); return(_orderConverter.OrderToGetOrderDto(_orderRepository.Update(id, updateOrder))); }