Exemple #1
0
        public ActionResult ImportStep1(string id)
        {
            BookingChannelImportStep1WithFileVM clientSubUnitImportStep1WithFileVM = new BookingChannelImportStep1WithFileVM();

            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit = clientSubUnitRepository.GetClientSubUnit(id);

            //Check Exists
            if (clientSubUnit == null)
            {
                ViewData["ActionMethod"] = "ListSubMenu";
                return(View("RecordDoesNotExistError"));
            }

            clientSubUnitImportStep1WithFileVM.ClientSubUnit     = clientSubUnit;
            clientSubUnitImportStep1WithFileVM.ClientSubUnitGuid = id;

            return(View(clientSubUnitImportStep1WithFileVM));
        }
Exemple #2
0
        public ActionResult ImportStep1(BookingChannelImportStep1WithFileVM csvfile)
        {
            //used for return only
            ClientSubUnit clientSubUnit = new ClientSubUnit();

            clientSubUnit         = clientSubUnitRepository.GetClientSubUnit(csvfile.ClientSubUnitGuid);
            csvfile.ClientSubUnit = clientSubUnit;

            if (!ModelState.IsValid)
            {
                return(View(csvfile));
            }
            string fileExtension = Path.GetExtension(csvfile.File.FileName);

            if (fileExtension != ".csv")
            {
                ModelState.AddModelError("file", "This is not a valid entry");
                return(View(csvfile));
            }

            if (csvfile.File.ContentLength > 0)
            {
                BookingChannelImportStep2VM preImportCheckResult = new BookingChannelImportStep2VM();
                List <string> returnMessages = new List <string>();

                preImportCheckResult = bookingChannelRepository.PreImportCheck(csvfile.File, csvfile.ClientSubUnitGuid);

                BookingChannelImportStep1VM preImportCheckResultVM = new BookingChannelImportStep1VM();
                preImportCheckResultVM.ClientSubUnit     = clientSubUnit;
                preImportCheckResultVM.ImportStep2VM     = preImportCheckResult;
                preImportCheckResultVM.ClientSubUnitGuid = csvfile.ClientSubUnitGuid;

                TempData["PreImportCheckResultVM"] = preImportCheckResultVM;
                return(RedirectToAction("ImportStep2"));
            }

            return(View());
        }