예제 #1
0
        public Product GetProductById(int id)
        {
            DAL.Entity.Product product       = _dal.GetProductById(id);
            BLL.Models.Product productResult = null;

            productResult = new BLL.Models.Product
            {
                Id             = product.Id,
                CategoryId     = product.CategoryId,
                ManufacturerId = product.ManufacturerId,
                Name           = product.Name,
                Description    = product.Description,
                Price          = product.Price,
                Keywords       = product.Keywords,
                Quantity       = product.Quantity
            };
            return(productResult);
        }
예제 #2
0
        public void AddToDatabase(Journal journal)
        {
            lock (this)
            {
                var newManager = new DAL.Entity.Manager {
                    ManagerName = journal.ManagerName
                };
                var manager = ManagerRepository.GetEntity(newManager);
                if (manager == null)
                {
                    ManagerRepository.Add(newManager);
                    ManagerRepository.SaveChanges();
                    manager = ManagerRepository.GetEntity(newManager);
                }

                var newClient = new DAL.Entity.Client {
                    ClientName = journal.ClientName
                };
                ClientRepository.Add(newClient);
                ClientRepository.SaveChanges();
                var client = ClientRepository.GetEntity(newClient);

                var newProduct = new DAL.Entity.Product {
                    ProductName = journal.ProductName, ProductCost = journal.ProductCost
                };
                ProductRepository.Add(newProduct);
                ProductRepository.SaveChanges();
                var product = ProductRepository.GetEntity(newProduct);

                var saleInfo = new DAL.Entity.SaleInfo
                {
                    SaleDate   = journal.SaleDate,
                    ID_Manager = manager.ID_Manager,
                    ID_Client  = client.ID_Client,
                    ID_Product = product.ID_Product
                };
                SaleInfoRepository.Add(saleInfo);
                SaleInfoRepository.SaveChanges();
            }
        }