コード例 #1
0
        public void ChangeSale(Sale sale, Manager newManger, Client newClient, Product newProduct)
        {
            var entitySale = _salesEntitiesList.FirstOrDefault(s => s.SaleID == sale.Id);
            if (entitySale == null)
                throw new ArgumentException("Cannot find current sale in data base");

            entitySale.ManagerID = newManger.Id;
            entitySale.ClientID = newClient.Id;
            entitySale.ProductID = newProduct.Id;
            _salesEntities.SaveChanges();

            sale.SetManger(newManger);
            sale.SetClient(newClient);
            sale.SetProduct(newProduct);
        }
コード例 #2
0
        public Sale AddNewSale(Manager manager, Client client, Product product, DateTime saleDate)
        {
            var entitySale = new Model.Entities.Sale()
            {
                ManagerID = manager.Id,
                ClientID = client.Id,
                ProductID = product.Id,
                SaleDate = saleDate
            };

            _salesEntities.Sales.Add(entitySale);
            _salesEntities.SaveChanges();

            _salesEntitiesList.Add(entitySale);
            return SaleEntityToModel(entitySale);
        }