예제 #1
0
        public void GenerateSaleProductsForSalespoint(Guid id)
        {
            var salespoint = _repo.GetOrThrow <Salespoint>(id);

            salespoint.RecalculateSaleproducts();
            _repo.Commit();
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }