public async Task <IActionResult> Create([FromBody] SaveBusOrderVerificationResource busOrderVerificationResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var OrderLists = busOrderVerificationResource.OrderList; var busOrderVerification = mapper.Map <SaveBusOrderVerificationResource, BusOrderVerification>(busOrderVerificationResource); foreach (int item in OrderLists) { var Order = await busOrderRepository.GetOne(item); Order.BusOrderVerification = busOrderVerification; } busOrderVerificationRepository.Add(busOrderVerification); if (await unitOfWork.CompleteAsync() == false) { throw new Exception(message: "Create new order failed on save"); } busOrderVerification = await busOrderVerificationRepository.GetOne(busOrderVerification.Id); var result = mapper.Map <BusOrderVerification, ViewBusOrderVerificationResource>(busOrderVerification); return(Ok(result)); }
public async Task <IActionResult> GetActionResult(int id) { var userId = getUserId(); var busOrder = await busOrderRepository.GetOne(id, userId); if (busOrder == null) { return(NotFound()); } var result = mapper.Map <BusOrder, ViewBusOrderResource>(busOrder); return(Ok(result)); }