Exemple #1
0
        public ActionResult Index()
        {
            var categoryServiceClient = new ServiceReference2.CategoryServiceClient();
            var supplierServiceClient = new ServiceReference1.SupplierServiceClient();

            List <string> listcategories = new List <string>();
            var           lc             = categoryServiceClient.GetCategories();

            foreach (var c in lc)
            {
                listcategories.Add(c.CategoryName);
            }

            if (listcategories.Count == 0)
            {
                listcategories.Add("no categories");
            }

            List <string> listSuppliers = new List <string>();
            var           ls            = supplierServiceClient.GetSuppliers();

            foreach (var c in ls)
            {
                listSuppliers.Add(c.CompanyName);
            }

            if (listSuppliers.Count == 0)
            {
                listSuppliers.Add("no categories");
            }

            ViewBag.categories = listcategories;
            ViewBag.suppliers  = listSuppliers;
            return(View());
        }
Exemple #2
0
        public ActionResult AddSupplier(SupplierTypeModel supplier)
        {
            var            supplierServiceClient = new ServiceReference1.SupplierServiceClient();
            SupplierDetail newSupplier           = new SupplierDetail
            {
                CompanyName  = supplier.CompanyName,
                ContactName  = supplier.ContactName,
                ContactTitle = supplier.ContactTitle,
                Country      = supplier.Country,
                Address      = supplier.Address,
                City         = supplier.City,
                Fax          = supplier.Fax,
                Region       = supplier.Region,
                Tel          = supplier.Tel,
                Website      = supplier.Website,
            };

            if (supplierServiceClient.AddSupplier(newSupplier))
            {
                Console.WriteLine("supplier a été ajouté");
                return(View());
            }
            else
            {
                return(View());
            }
        }
Exemple #3
0
        public ActionResult Index(String name)
        {
            var suppliername          = name;
            var supplierServiceClient = new ServiceReference1.SupplierServiceClient();

            List <SupplierTypeModel> response = new List <SupplierTypeModel>();

            List <ServiceReference1.SupplierType> listSuppliers = supplierServiceClient.GetSupplierByName(suppliername);

            if (listSuppliers == null)
            {
                Session["SupplierFound"] = 0;
                return(View("Index"));
            }
            else
            {
                foreach (var s in listSuppliers)
                {
                    SupplierTypeModel supplier = new SupplierTypeModel()
                    {
                        CompanyName   = s.CompanyName,
                        SupplierId    = s.SupplierId,
                        ContactName   = s.ContactName,
                        ContactTitle  = s.ContactTitle,
                        Country       = s.Country,
                        ExtensionData = s.ExtensionData
                    };
                    response.Add(supplier);
                }
                Session["SupplierFound"] = 1;
                return(View("Index", response));
            }
        }
Exemple #4
0
        /************************************ Delete Supplier ****************************************
         * ************************************************************************************************************/

        public ActionResult Delete(long id)
        {
            var supplierServiceClient = new ServiceReference1.SupplierServiceClient();

            supplierServiceClient.DelSupplier(id);
            return(RedirectToAction("Index"));
        }
Exemple #5
0
        /************************************ Show Supplier Details ****************************************
         * ************************************************************************************************************/


        public ActionResult Details(long id)
        {
            var supplierServiceClient = new ServiceReference1.SupplierServiceClient();
            var supplier = supplierServiceClient.GetSupplierDetail(id);

            SupplierTypeModel SupplierById = new SupplierTypeModel
            {
                CompanyName  = supplier.CompanyName,
                ContactName  = supplier.ContactName,
                ContactTitle = supplier.ContactTitle,
                Country      = supplier.Country,
                Address      = supplier.Address,
                City         = supplier.City,
                Fax          = supplier.Fax,
                Region       = supplier.Region,
                Tel          = supplier.Tel,
                Website      = supplier.Website,
            };

            SupplierById.SupplierId = id;

            return(View(SupplierById));
        }
Exemple #6
0
        public ActionResult Edit(SupplierTypeModel supplier)
        {
            var            supplierServiceClient = new ServiceReference1.SupplierServiceClient();
            SupplierDetail newSupplier           = new SupplierDetail
            {
                CompanyName  = supplier.CompanyName,
                ContactName  = supplier.ContactName,
                ContactTitle = supplier.ContactTitle,
                Country      = supplier.Country,
                Address      = supplier.Address,
                City         = supplier.City,
                Fax          = supplier.Fax,
                Region       = supplier.Region,
                Tel          = supplier.Tel,
                Website      = supplier.Website,
            };

            newSupplier.SupplierId = (long)Session["SupplierIdModified"];

            supplierServiceClient.UpdateSupplier(newSupplier);
            Session["SupplierIdModified"] = -1;
            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public ActionResult Index(string name, String listCategories, String listSuppliers, bool inStock, bool discontinued)
        {
            var productServiceClient = new ServiceReference3.ProductServiceClient();

            var response = new List <ProductDetailModel>();


            var supplierServiceClient = new ServiceReference1.SupplierServiceClient();

            var  categoryServiceClient = new ServiceReference2.CategoryServiceClient();
            long?supplierId;
            long?categoryId;

            try
            {
                supplierId = supplierServiceClient.GetSupplierByName(listCategories).Single().SupplierId;
            }
            catch (Exception e)
            {
                supplierId = null;
            }

            try
            {
                categoryId = categoryServiceClient.GetCategoryByName(listSuppliers).Single().CategoryId;
            }
            catch (Exception e)
            {
                categoryId = null;
            }

            var listProducts = productServiceClient.GetProducts(name, supplierId, categoryId, inStock, discontinued);

            if (!listProducts.Any())
            {
                Session["ProductFound"] = 0;
                return(View("Index"));
            }

            response.AddRange(listProducts.Select(s => new ProductDetailModel()
            {
                UnitsInStock = s.UnitsInStock, CategoryId = s.CategoryId, Discontinued = s.Discontinued, ProductName = s.ProductName, QuantityPerUnit = s.QuantityPerUnit,
                SupplierId   = s.SupplierId, ReorderLevel = s.ReorderLevel, UnitPrice = s.UnitPrice, UnitsOnOrder = s.UnitsOnOrder
            }));
            Session["ProductFound"] = 1;



            List <string> listcategories = new List <string>();
            var           lc             = categoryServiceClient.GetCategories();

            foreach (var c in lc)
            {
                listcategories.Add(c.CategoryName);
            }

            if (listcategories.Count == 0)
            {
                listcategories.Add("no categories");
            }

            List <string> listSuppliers2 = new List <string>();
            var           ls             = supplierServiceClient.GetSuppliers();

            foreach (var c in ls)
            {
                listSuppliers2.Add(c.CompanyName);
            }

            if (listSuppliers2.Count == 0)
            {
                listSuppliers2.Add("no categories");
            }

            ViewBag.categories = listcategories;
            ViewBag.suppliers  = listSuppliers2;


            return(View("Index", response));
        }