コード例 #1
0
        /// <summary>
        /// Controller method that takes the user to the page to
        /// create a staging table. No parameters are needed and
        /// the controller needs no data access. 
        /// 
        /// Accessed via /Staging/CreateStaging
        /// </summary>
        /// <returns></returns>
        public ActionResult CreateStaging()
        {
            GeneralStagingModel model = new GeneralStagingModel();

            List<Breadcrumb> trail = new List<Breadcrumb>();

            trail.Add(new Breadcrumb() { LinkText = "Home", Action = "Index", Controller = "Home", isCurrent = false });
            trail.Add(new Breadcrumb() { LinkText = "Staging Index", Action = "Index", Controller = "Staging", isCurrent = false });
            trail.Add(new Breadcrumb() { LinkText = "Create Staging", isCurrent = true });

            model.Breadcrumbs = trail;

            return View(model);
        }
コード例 #2
0
        public ActionResult CreateStaging(GeneralStagingModel model)
        {
            StagingDataAccess dataAccess = new StagingDataAccess();

            if (!dataAccess.isCreateStagingModelValid(model))
            {
                ModelState.AddModelError("TableName", "The Staging Table Name must be unique");

                List<Breadcrumb> trail = new List<Breadcrumb>();

                trail.Add(new Breadcrumb() { LinkText = "Home", Action = "Index", Controller = "Home", isCurrent = false });
                trail.Add(new Breadcrumb() { LinkText = "Staging Index", Action = "Index", Controller = "Staging", isCurrent = false });
                trail.Add(new Breadcrumb() { LinkText = "Create Staging", isCurrent = true });

                model.Breadcrumbs = trail;

                return View(model);
            }

            try
            {
                dataAccess.createStagingTable(model);
            }
            catch (SqlException)
            {
                ModelState.AddModelError("", "An error occured when creating the Staging Table. Please ensure that the staging table name is unique and that all columns within it are uniquely named");

                List<Breadcrumb> trail = new List<Breadcrumb>();

                trail.Add(new Breadcrumb() { LinkText = "Home", Action = "Index", Controller = "Home", isCurrent = false });
                trail.Add(new Breadcrumb() { LinkText = "Staging Index", Action = "Index", Controller = "Staging", isCurrent = false });
                trail.Add(new Breadcrumb() { LinkText = "Create Staging", isCurrent = true });

                model.Breadcrumbs = trail;

                return View(model);
            }

            TempData["SuccessMessage"] = String.Format("The Staging Table - {0}, was successfully created", model.TableName);
            return RedirectToAction("Index");
        }