Esempio n. 1
0
        public ActionResult OrderImport(OrderImportFile model)
        {
            var clientfolder = ""; // initialize
            var clients = GetClients();
            model.Clients = GetSelectListItems(clients);
            var client = model.Client;

            // Change folders based on client dropdown selection.
            switch (client)
            {
                case "Akzo Nobel":
                    clientfolder = "AkzoNobel";
                    break;

                case "Archroma":
                    clientfolder = "Archroma";
                    break;

                case "Clariant":
                    clientfolder = "Clariant";
                    break;

                case "Cytec":
                    clientfolder = "Cytec";
                    break;

                case "Dow Chemical":
                    clientfolder = "DowChem";
                    break;

                case "DSM":
                    clientfolder = "DSM";
                    break;

                case "Eastman":
                    clientfolder = "Eastman";
                    break;

                case "Elementis":
                    clientfolder = "Elementis";
                    break;

                case "Honeywell":
                    clientfolder = "Honeywell";
                    break;

                case "Lonza":
                    clientfolder = "Lonza";
                    break;

                case "Momentive":
                    clientfolder = "Momentive";
                    break;

                case "OMG":
                    clientfolder = "OMG";
                    break;

                case "Reichhold":
                    clientfolder = "Reichhold";
                    break;

                case "Stepan":
                    clientfolder = "Stepan";
                    break;

                case "Sun Chemical":
                    clientfolder = "SunChem";
                    break;

                default:
                    TempData["message"] = "Please select a client from the dropdown list";

                    return RedirectToAction("Index");
            }

            try
            {
                foreach (var file in model.Files)
                {
                    if (file.ContentLength != 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path = Path.Combine(Server.MapPath("~/Content/OrderImportFiles/" + clientfolder), fileName);
                        file.SaveAs(path);
                        TempData["message"] = String.Format("The {0} order import files uploaded successfully", client);
                    }
                }
            }
            catch (Exception)
            {
                TempData["message"] = "Please make sure you browse and select at least a file";
            }
            return RedirectToAction("Index");
        }
Esempio n. 2
0
        public ActionResult OrderImport()
        {
            var clients = GetClients(); // Let's get all clients that we need for a DropDownList
            var model = new OrderImportFile();
            model.Clients = GetSelectListItems(clients);  // Create a list of SelectListItems so these can be rendered on the page

            return View(model);
        }