public static OrderViewModel Create(Order order) { if (order == null) { throw new Exception("Order cannot be null"); } var grower = GrowerViewModel.Create(order.Grower); if (grower == null) { throw new Exception("Grower cannot be null"); } OrderViewModel vm = new OrderViewModel ( id: order.Id, name: order.Name, year: order.Year, grower: grower, genusId: order.GenusId, growerId: order.GrowerId, growerName: grower.FullName, locationId: order.LocationId, locationName: order.Location?.Name, locationAddress: order.Location?.Address, note: order.Note, mtaRequestedProp: order.MTARequestedProp, mtaRequestedTest: order.MTARequestedTest, mtaComplete: order.MTAComplete ); return(vm); }
public static LocationViewModel Create(Location location) { if (location == null) { return(null); } var growerVM = GrowerViewModel.Create(location.Grower); return(new LocationViewModel { Id = location.Id, Name = location.Name, MapFlag = location.MapFlag, Description = location.Description, PrimaryContactId = location.PrimaryContactId, Retired = location.Retired, Grower = growerVM, PrimaryContactName = growerVM?.FullName, Address = location.Address }); }