public static VendorOrderItemViewModel Create(IUnitOfWork db) { var model = new VendorOrderItemViewModel(); model.Sizes = new List <VendorOrderItemSizeViewModel>(); model.Images = new List <ImageViewModel>() { new ImageViewModel() }; return(model); }
public static VendorOrderItemViewModel GetById(IUnitOfWork db, long id) { var itemDto = db.VendorOrderItems.GetAllAsDto().FirstOrDefault(i => i.Id == id); var model = new VendorOrderItemViewModel(itemDto); model.Sizes = db.VendorOrderItemSizes.GetAllAsDto() .Where(s => s.VendorOrderItemId == model.Id) .ToList() .OrderBy(s => s.Order) .Select(s => new VendorOrderItemSizeViewModel(s)) .ToList(); return(model); }