public async Task <OrderForm> PlaceOrder(OrderRequest request) { var model = request.GetModel(); await _orderRepository.AddAsync(model); var isAdded = await _orderRepository.SaveAsync(); if (isAdded > 0 && request.OrderServices != null) { await _orderServicesRepository.AddListOfServices(request.OrderServices, model.Id); } return(model); }
public async Task <OrderForm> EditOrder(OrderRequest request, int id) { var model = request.GetModel(); model.Id = id; _orderRepository.Update(model); var isEdited = await _orderRepository.SaveAsync(); if (request.OrderServices != null) { await _orderServicesRepository.DeleteListOfServices(model.Id); await _orderServicesRepository.AddListOfServices(request.OrderServices, model.Id); } return(model); }