Beispiel #1
0
        public async Task <ActionResult> ManageTemplates()
        {
            try
            {
                var checkUsageCountData = await CheckIsUsageExceededAsync();

                var location             = checkUsageCountData.Item1;
                var monthlyFormOpenCount = checkUsageCountData.Item2;
                var isUsageExceeded      = checkUsageCountData.Item3;

                using (var context = SpManager.GetSharePointContext(HttpContext))
                {
                    if (!SpManager.IsUserAdmin(context))
                    {
                        return(AccessDenied());
                    }

                    var templates = await GetTemplatesAsync();

                    return(View(new ManageTemplatesViewModel
                    {
                        Templates = templates,
                        MonthlyFormOpenCount = monthlyFormOpenCount,
                        Location = location,
                        IsUsageExceeded = isUsageExceeded
                    }));
                }
            }
            catch (Exception e)
            {
                throw QfsUtility.HandleException(e);
            }
        }
Beispiel #2
0
        public async Task <ActionResult> ManageHrefs()
        {
            try
            {
                using (var context = SpManager.GetSharePointContext(HttpContext))
                {
                    if (!SpManager.IsUserAdmin(context))
                    {
                        return(AccessDenied());
                    }

                    var userKey   = GetUserKey();
                    var templates = await GetTemplatesAsync(userKey);

                    var hrefs = (await SQLTemplateStorageManager.ListHrefAssociations(userKey)).ToList();

                    return(View(new ManageHrefsModel
                    {
                        Hrefs = hrefs,
                        Templates = templates
                    }));
                }
            }
            catch (Exception e)
            {
                throw QfsUtility.HandleException(e);
            }
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                if (filterContext == null)
                {
                    throw new ArgumentNullException("filterContext");
                }

                Uri redirectUrl;
                switch (SharePointContextProvider.CheckRedirectionStatus(filterContext.HttpContext, out redirectUrl))
                {
                case RedirectionStatus.Ok:
                    return;

                case RedirectionStatus.ShouldRedirect:
                    filterContext.Result = new RedirectResult(redirectUrl.AbsoluteUri);
                    break;

                case RedirectionStatus.CanNotRedirect:
                    filterContext.Result = new ViewResult {
                        ViewName = "Error"
                    };
                    break;
                }
            }
            catch (Exception e)
            {
                throw QfsUtility.HandleException(e);
            }
        }