public void GenerateSaleProductsForSalespoint(Guid id) { var salespoint = _repo.GetOrThrow <Salespoint>(id); salespoint.RecalculateSaleproducts(); _repo.Commit(); }
public IObjectIdentifier Save(EditProductMasterModel input) { input.Validate().OrThrowPropertyError(); var producer = _repo.GetOrThrow <Producer>(input.ProducerId); var productType = _repo.GetOrThrow <ProductType>(input.ProductTypeId); var master = input.IsNew ? new ProductMaster() : _repo.GetOrThrow <ProductMaster>(input.Id); master.Name = input.Name; master.Description = input.Description; master.ProductType = productType; producer.Add(master); _repo.Commit(); return(new ObjectIdentifier(master.Name)); }
public IObjectIdentifier Save(ProducerModel input) { var producer = input.IsNew ? new Producer() : _repo.GetOrThrow <Producer>(input.Id); producer.Name = input.Name; _repo.Save(producer); _repo.Commit(); return(new ObjectIdentifier(producer.Name)); }
public IObjectIdentifier Save(ProductTypeModel input) { var type = input.IsNew ? new ProductType() : _repo.GetOrThrow <ProductType>(input.Id); type.Name = input.Name; type.VatRate = input.VatRate; _repo.Save(type); _repo.Commit(); return(new ObjectIdentifier(input.Name)); }
public IObjectIdentifier Save(EditColorModel input) { input.Validate().OrThrowPropertyError(); var color = input.IsNew ? new Color() : _repo.GetOrThrow <Color>(input.Id); color.Name = input.Name; color.Red = input.Red; color.Green = input.Green; color.Blue = input.Blue; color.Alpha = input.Alpha; _repo.Save(color); _repo.Commit(); return(new ObjectIdentifier(color.Name)); }
public IObjectIdentifier Save(EditSupplierModel input) { var supplier = input.IsNew ? new Supplier() : _repo.GetOrThrow <Supplier>(input.Id); supplier.Name = input.Name; var existing = supplier.Products.ToList(); var productsToAdd = input.Products.Where(p => p.Checked && existing.All(sp => sp.Variant.Id != p.Id)); var productsToRemove = existing.Where(sp => input.Products.Any(p => !p.Checked && p.Id == sp.Variant.Id)); foreach (var toRemove in productsToRemove) { supplier.Remove(toRemove); _repo.Delete(toRemove); } foreach (var toAdd in productsToAdd) { supplier.Add(new SupplierProduct(_repo.Get <ProductVariant>(toAdd.Id))); } _repo.Save(supplier); _repo.Commit(); return(new ObjectIdentifier(supplier.Name)); }