Exemplo n.º 1
0
        public bool CreateNewOrder(string companyName, string productName, int count, DateTime finishDate)
        {
            Company company = CompanyRepository.GetComapny(companyName);

            if (company == null)
            {
                return(false);
            }
            CompanyProduct companyProduct = ProductsInfoRepository.GetCompanyProducts(company).
                                            FirstOrDefault(product => product.Product.Name.Equals(productName));

            if (companyProduct == null)
            {
                return(false);
            }
            if (count <= 0)
            {
                return(false);
            }
            Order order = new Order
            {
                Customer        = _customer,
                CompanieProduct = companyProduct,
                Count           = count,
                FinishDate      = finishDate,
                IsFinished      = false,
                IsStarted       = false
            };

            OrderCustomerRepository.CreateNewOrder(order);
            OrderCustomerRepository.SaveChages();
            return(true);
        }
Exemplo n.º 2
0
 public List <(int Id, string ProductName, string CompanyName, int Cost)> GetProductsByName(string productName)
 {
     return(ProductsInfoRepository.GetProductsByName(productName).
            Select <CompanyProduct, (int Id, string ProductName, string CompanyName, int Cost)>
                (compProd => (compProd.Id, compProd.Product.Name, compProd.Company.Name, compProd.Cost)).
            ToList());
 }
Exemplo n.º 3
0
 public CompanyProduct GetCompanyProductByProductId(int companyProductId)
 {
     return(ProductsInfoRepository.GetProductById(companyProductId));
 }