public Guid AddOrder(OrderDTO orderModel) { Order dataModel = new Order(); orderModel.CopyTo(dataModel); _context.Orders.Add(dataModel); _context.SaveChanges(); return(dataModel.Id); }
public void UpdateOrder(OrderDTO orderModel) { Order dataModel = _context.Orders.Include(x => x.PricelistOrders).FirstOrDefault(x => x.Id == orderModel.Id); if (dataModel == null) { return; } orderModel.CopyTo(dataModel); //_context.Entry(dataModel).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return; }
public static Order ToOrder(this OrderDTO dto) => dto?.CopyTo(new Order());