internal async Task <Shared.Order> UpdateOrderByIdAsync(int id, Shared.Order order) { Shared.Order o = GetOrderById(id); _AirTechContext.Order.Update(ConvertToDal(order)); _AirTechContext.SaveChangesAsync().Wait(); List <Models.Order> orders = _AirTechContext.Order.Include(x => x.Cilent).Include(x => x.Billet).OrderByDescending(t => t.Id).ToList(); Models.Order final = orders.FirstOrDefault <Models.Order>(); return(ConvertToEndPoint(final)); }
public async Task <Shared.Order> CreateOrderAsync(Shared.Order order) { await _AirTechContext.Order.AddAsync(ConvertToDal(order)); await _AirTechContext.SaveChangesAsync(); List <Models.Order> orders = _AirTechContext.Order.Include(x => x.Cilent).Include(x => x.Billet).OrderByDescending(t => t.Id).ToList(); Models.Order final = orders.FirstOrDefault <Models.Order>(); return(ConvertToEndPoint(final)); }
public static Models.Order ConvertToDal(Shared.Order model) { return(new Models.Order { Id = model.Id, TotalAmount = model.TotalAmount, CilentId = model.CilentId, Cilent = ClientDAO.ConvertToDal(model.Cilent), Billet = BilletDAO.ConvertToDal(model.Billet) }); }
public async Task <Shared.Order> UpdateOrderById(int id, [FromBody] Shared.Order order) { try { return(await _dao.UpdateOrderByIdAsync(id, order)); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); return(null); } }
public async Task <Shared.Order> AddOrder([FromBody] Shared.Order order) { try { return(await _dao.CreateOrderAsync(order)); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); return(null); } }