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 OrderViewModel( int id, string name, int year, int genusId, int growerId, GrowerViewModel grower, string growerName, int?locationId, string locationName, string locationAddress, string note, bool mtaRequestedProp, bool mtaRequestedTest, DateTime?mtaComplete ) { Id = id; Name = name; Year = year; GenusId = genusId; Grower = grower; GrowerId = growerId; GrowerName = growerName; LocationId = locationId; LocationName = locationName; LocationAddress = locationAddress; Note = note; MTARequestedProp = mtaRequestedProp; MTARequestedTest = mtaRequestedTest; MTAComplete = mtaComplete; }
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 }); }