public async Task <ActionResult> New(Tenant tenant)
        {
            if (string.IsNullOrWhiteSpace(tenant.TenantId))
            {
                var model = new TenantPageViewData <Tenant>(tenant)
                {
                    Title = "New Tenant : Error!"
                };
                this.ViewData["error"] = "Organization's name cannot be empty";
                return(this.View(model));
            }
            else if (tenant.TenantId.Equals("new", System.StringComparison.InvariantCultureIgnoreCase))
            {
                var model = new TenantPageViewData <Tenant>(tenant)
                {
                    Title = "New Tenant : Error!"
                };
                this.ViewData["error"] = "Organization's name cannot be 'new'";
                return(this.View(model));
            }

            // TODO: check if tenant already exist
            await this.tenantStore.SaveTenantAsync(tenant);

            return(this.RedirectToAction("Index"));
        }
        public async Task <ActionResult> Index()
        {
            var model = new TenantPageViewData <IEnumerable <Survey> >(await this.surveyStore.GetRecentSurveysAsync());

            model.Title = "Existing surveys";
            return(this.View(model));
        }
        public ActionResult Display(string tenant, string surveySlug, SurveyAnswer contentModel)
        {
            var surveyAnswer = this.CallGetSurveyAndCreateSurveyAnswer(tenant, surveySlug);

            if (surveyAnswer == null)
            {
                return this.View(new TenantPageViewData<SurveyAnswer>(surveyAnswer));
            }

            if (surveyAnswer.QuestionAnswers.Count != contentModel.QuestionAnswers.Count)
            {
                throw new ArgumentException("The survey answers received have different amount of questions than the survey to be filled.");
            }

            for (int i = 0; i < surveyAnswer.QuestionAnswers.Count; i++)
            {
                surveyAnswer.QuestionAnswers[i].Answer = contentModel.QuestionAnswers[i].Answer;
            }

            if (!this.ModelState.IsValid)
            {
                var model = new TenantPageViewData<SurveyAnswer>(surveyAnswer);
                model.Title = surveyAnswer.Title;
                return this.View(model);
            }

            this.surveyAnswerStore.SaveSurveyAnswer(surveyAnswer);

            return this.RedirectToAction("ThankYou");
        }
        public async Task <ActionResult> Display(string tenantId, string surveySlug, SurveyAnswer contentModel)
        {
            var surveyAnswer = await this.CallGetSurveyAndCreateSurveyAnswerAsync(tenantId, surveySlug);

            if (surveyAnswer.QuestionAnswers.Count != contentModel.QuestionAnswers.Count)
            {
                throw new ArgumentException("The survey answers received have different amount of questions than the survey to be filled.");
            }

            for (int i = 0; i < surveyAnswer.QuestionAnswers.Count; i++)
            {
                surveyAnswer.QuestionAnswers[i].Answer = contentModel.QuestionAnswers[i].Answer;
            }

            if (!this.ModelState.IsValid)
            {
                var model = new TenantPageViewData <SurveyAnswer>(surveyAnswer);
                model.Title = surveyAnswer.Title;
                return(this.View(model));
            }

            await this.surveyAnswerStore.SaveSurveyAnswerAsync(surveyAnswer);

            return(this.RedirectToAction("ThankYou"));
        }
 public ActionResult Index()
 {
     var model = new TenantPageViewData<IEnumerable<string>>(this.tenantStore.GetTenantNames())
     {
         Title = "Subscribers"
     };
     return this.View(model);
 }
 public ActionResult New()
 {
     var model = new TenantPageViewData<Tenant>(new Tenant())
     {
         Title = "New Tenant"
     };
     return this.View(model);
 }
 public ActionResult Detail(string tenant)
 {
     var contentModel = this.tenantStore.GetTenant(tenant);
     var model = new TenantPageViewData<Tenant>(contentModel)
     {
         Title = string.Format("{0} details", contentModel.Name)
     };
     return this.View(model);
 }
        public ActionResult Display(string tenant, string surveySlug)
        {
            var surveyAnswer = this.CallGetSurveyAndCreateSurveyAnswer(tenant, surveySlug);

            var model = new TenantPageViewData <SurveyAnswer>(surveyAnswer);

            model.Title = surveyAnswer.Title;
            return(this.View(model));
        }
Esempio n. 9
0
        public TenantPageViewData <T> CreateTenantPageViewData <T>(T contentModel)
        {
            var tenantPageViewData = new TenantPageViewData <T>(contentModel)
            {
                Tenant = this.Tenant
            };

            return(tenantPageViewData);
        }
Esempio n. 10
0
        public TenantPageViewData <T> CreateTenantPageViewData <T>(T contentModel)
        {
            var tenantPageViewData = new TenantPageViewData <T>(contentModel)
            {
                LogoUrl = this.Tenant == null ? string.Empty : this.Tenant.Logo
            };

            return(tenantPageViewData);
        }
        public ActionResult New()
        {
            var model = new TenantPageViewData <Tenant>(new Tenant())
            {
                Title = "New Tenant"
            };

            return(this.View(model));
        }
        public async Task <ActionResult> Display(string tenantId, string surveySlug)
        {
            var surveyAnswer = await this.CallGetSurveyAndCreateSurveyAnswerAsync(tenantId, surveySlug);

            var model = new TenantPageViewData <SurveyAnswer>(surveyAnswer);

            model.Title = surveyAnswer.Title;
            return(this.View(model));
        }
        public ActionResult Index()
        {
            var model = new TenantPageViewData <IEnumerable <string> >(this.tenantStore.GetTenantIds())
            {
                Title = "Subscribers"
            };

            return(this.View(model));
        }
Esempio n. 14
0
        public ActionResult Detail(string tenant)
        {
            var contentModel = this.tenantStore.GetTenant(tenant);
            var model        = new TenantPageViewData <Tenant>(contentModel)
            {
                Title = string.Format("{0} details", contentModel.Name)
            };

            return(this.View(model));
        }
Esempio n. 15
0
        public ActionResult Display(string tenant, string surveySlug)
        {
            var surveyAnswer = this.CallGetSurveyAndCreateSurveyAnswer(tenant, surveySlug);

            var model = new TenantPageViewData<SurveyAnswer>(surveyAnswer);
            if (surveyAnswer != null)
            {
                model.Title = surveyAnswer.Title;
            }
            return this.View(model);
        }
        public async Task <ActionResult> Detail(string tenantId)
        {
            var contentModel = await this.tenantStore.GetTenantAsync(tenantId);

            var model = new TenantPageViewData <Tenant>(contentModel)
            {
                Title = string.Format("{0} details", contentModel.TenantId)
            };

            return(this.View(model));
        }
Esempio n. 17
0
        protected async Task <TenantPageViewData <T> > CreateTenantPageViewDataAsync <T>(T contentModel)
        {
            var tenant = await GetTenantAsync();

            var tenantPageViewData = new TenantPageViewData <T>(contentModel)
            {
                LogoUrl = tenant?.Logo ?? string.Empty
            };

            return(tenantPageViewData);
        }
        public ActionResult Index()
        {
            IList<Tenant> tenants = new List<Tenant>();
            foreach (var tenantName in this.tenantStore.GetTenantNames())
            {
                tenants.Add(this.tenantStore.GetTenant(tenantName));
            }

            var model = new TenantPageViewData<IEnumerable<Tenant>>(tenants)
            {
                Title = "On boarding"
            };
            return this.View(model);
        }
        public ActionResult Index()
        {
            IList <Tenant> tenants = new List <Tenant>();

            foreach (var tenantName in this.tenantStore.GetTenantNames())
            {
                tenants.Add(this.tenantStore.GetTenant(tenantName));
            }

            var model = new TenantPageViewData <IEnumerable <Tenant> >(tenants)
            {
                Title = "On boarding"
            };

            return(this.View(model));
        }
        public async Task <ActionResult> Index()
        {
            IList <Tenant> tenants = new List <Tenant>();

            foreach (var tenantId in this.tenantStore.GetTenantIds())
            {
                tenants.Add(await this.tenantStore.GetTenantAsync(tenantId));
            }

            var model = new TenantPageViewData <IEnumerable <Tenant> >(tenants)
            {
                Title = "On boarding"
            };

            return(View(model));
        }
Esempio n. 21
0
        public ActionResult New(Tenant tenant)
        {
            if (string.IsNullOrWhiteSpace(tenant.Name) || tenant.Name.Equals("new", System.StringComparison.InvariantCultureIgnoreCase))
            {
                this.ModelState.AddModelError("ContentModel.Name", "* Organization name cannot be empty or 'new'.");
            }
            else if (this.tenantStore.GetTenant(tenant.Name) != null)
            {
                this.ModelState.AddModelError("ContentModel.Name", "* Organization name already used.");
            }

            if (!this.ModelState.IsValid)
            {
                var model = new TenantPageViewData <Tenant>(tenant)
                {
                    Title = "New Tenant : Error!"
                };
                return(this.View(model));
            }

            this.tenantStore.SaveTenant(tenant);

            return(this.RedirectToAction("Index"));
        }
Esempio n. 22
0
 public ActionResult Index()
 {
     var model = new TenantPageViewData<IEnumerable<Survey>>(this.surveyStore.GetRecentSurveys());
     model.Title = "Existing surveys";
     return this.View(model);
 }
        public ActionResult New(Tenant tenant)
        {
            if (string.IsNullOrWhiteSpace(tenant.Name) || tenant.Name.Equals("new", System.StringComparison.InvariantCultureIgnoreCase))
            {
                this.ModelState.AddModelError("ContentModel.Name", "* Organization name cannot be empty or 'new'.");
            }
            else if (this.tenantStore.GetTenant(tenant.Name) != null)
            {
                this.ModelState.AddModelError("ContentModel.Name", "* Organization name already used.");
            }

            if (!this.ModelState.IsValid)
            {
                var model = new TenantPageViewData<Tenant>(tenant)
                {
                    Title = "New Tenant : Error!"
                };
                return this.View(model);
            }

            this.tenantStore.SaveTenant(tenant);

            return this.RedirectToAction("Index");
        }