/* Add to DB actions */ public string AddOrder(int carId, int workerId, int clientId, AddOrderDto addOrderDto) { if (!addOrderDto.Validate()) { return("Validation error!"); } var order = _orderConverter.AddOrderDtoToOrder(addOrderDto); var car = _carRepository.Get(carId); var worker = _workerRepository.Get(workerId); car.WorkerId = worker.Id; car.Worker = worker; car.IsAway = true; worker.Car = car; order.CarId = carId; order.WorkerId = workerId; order.ClientId = clientId; order.Finished = false; order.Cost = order.RentalTime * car.PricePerDay; _orderRepository.Add(order); return($"Order with id {order.Id} was succesfuly deleted"); }
public async Task <ActionResult> Post([FromBody] AddOrderDto order) { order.Validate <AddOrderDtoValidator, AddOrderDto>(); var orderResult = await _serviceFactory.OrderService.AddAsync(order.Number); return(Ok(orderResult)); }