public EditProductVariantModel NewVariantForMaster(Guid id) { var master = _repo.GetOrThrow <ProductMaster>(id); var model = new EditProductVariantModel { MasterId = master.Id, AvailableColors = GetAvailableColors(), Name = master.Name }; return(model); }
public IObjectIdentifier Save(EditProductVariantModel input) { input.Validate().OrThrowPropertyError(); var master = _repo.GetOrThrow <ProductMaster>(input.MasterId); var variant = input.IsNew ? new ProductVariant() : _repo.GetOrThrow <ProductVariant>(input.Id); if (variant.IsNew) { master.Add(variant); } variant.Name = input.Name; variant.Description = input.Description.OwnValue; variant.ProductNumber = input.ProductNumber; variant.Color = _repo.GetOrThrow <Color>(input.ColorId); _repo.Commit(); return(new ObjectIdentifier(variant.GetName())); }