Exemple #1
0
        public ActionResult CreateMeasure(CreateMeasureModel model)
        {
            DatasetDataAccess dataAccess = new DatasetDataAccess();

            if (ModelState.IsValid)
            {
                if (!dataAccess.isCreateMeasureModelValid(model))
                {
                    ModelState.AddModelError("", "An error occured when creating the Measure. Please ensure that the Measure name is unique and that Dimensions have been specified");

                    model = dataAccess.populateCreateMeasureModel(model.StagingDatasetID);

                    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 Measure", Action = "", Controller = "", isCurrent = true
                    });


                    model.Breadcrumbs = trail;

                    return(View(model));
                }
                dataAccess.createMeasure(model);

                IEnumerable <Tuple <int, int> > dimensionMappings = model.MeasureDetails.Where(x => x.DimensionValueID.HasValue).Select(x => new Tuple <int, int>(x.StagingColumnID, x.DimensionValueID.Value));

                TempData["DimensionMappings"] = dimensionMappings;

                return(RedirectToAction("AddMeasureValues", new
                {
                    stagingTableName = model.StagingTableName,
                    measureName = model.MeasureName,
                    measureColumnStagingID = model.MeasureColumnID,
                    geographyColumnID = model.GeographyColumnID,
                    geographyTypeID = model.GeographyTypeID
                }));
            }

            model = dataAccess.populateCreateMeasureModel(model.StagingDatasetID);

            return(View(model));
        }
Exemple #2
0
        /// <summary>
        /// The controller method to navigate to the page used to
        /// initiate the creation of a Measure. This is the first page in a
        /// two page process. Initially all that is needed is a Staging
        /// Dataset ID to use to populate the model.
        ///
        /// Accessed from /Dataset/CreateMeasure
        /// </summary>
        /// <param name="stagingDatasetID"></param>
        /// <returns></returns>
        public ActionResult CreateMeasure(int stagingDatasetID)
        {
            DatasetDataAccess dataAccess = new DatasetDataAccess();

            CreateMeasureModel model = dataAccess.populateCreateMeasureModel(stagingDatasetID);

            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 Measure", Action = "", Controller = "", isCurrent = true
            });


            model.Breadcrumbs = trail;

            return(View(model));
        }