Exemple #1
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldInfoList      = FieldManager.GetFieldInfoList(pollInfo.Id);
                var listAttributeNames = PollUtils.StringCollectionToStringList(pollInfo.ListAttributeNames);
                var allAttributeNames  = PollManager.GetAllAttributeNames(fieldInfoList);

                var pages = Convert.ToInt32(Math.Ceiling((double)pollInfo.TotalCount / PollUtils.PageSize));
                if (pages == 0)
                {
                    pages = 1;
                }
                var page = request.GetQueryInt("page", 1);
                if (page > pages)
                {
                    page = pages;
                }
                var logInfoList = LogManager.Repository.GetLogInfoList(pollInfo, page);

                var logs = new List <Dictionary <string, object> >();
                foreach (var logInfo in logInfoList)
                {
                    logs.Add(LogManager.GetDict(fieldInfoList, logInfo));
                }

                return(Ok(new
                {
                    Value = logs,
                    Count = pollInfo.TotalCount,
                    Pages = pages,
                    Page = page,
                    FieldInfoList = fieldInfoList,
                    AllAttributeNames = allAttributeNames,
                    ListAttributeNames = listAttributeNames
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #2
0
        public void Insert(int siteId, FieldInfo fieldInfo)
        {
            fieldInfo.Taxis = GetMaxTaxis(fieldInfo.PollId) + 1;

            fieldInfo.Id = _repository.Insert(fieldInfo);

            FieldManager.ItemRepository.InsertItems(fieldInfo.PollId, fieldInfo.Id, fieldInfo.Items);

            var formInfo = PollManager.GetPollInfo(siteId, fieldInfo.PollId);
            var list     = PollUtils.StringCollectionToStringList(formInfo.ListAttributeNames);

            list.Add(fieldInfo.Title);
            formInfo.ListAttributeNames = PollUtils.ObjectCollectionToString(list);
            PollManager.Repository.Update(formInfo);

            FieldManager.ClearCache(fieldInfo.PollId);
        }
Exemple #3
0
        public IHttpActionResult Visible()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var attributeName = request.GetPostString("attributeName");

                var attributeNames = PollUtils.StringCollectionToStringList(pollInfo.ListAttributeNames);
                if (attributeNames.Contains(attributeName))
                {
                    attributeNames.Remove(attributeName);
                }
                else
                {
                    attributeNames.Add(attributeName);
                }

                pollInfo.ListAttributeNames = PollUtils.ObjectCollectionToString(attributeNames);
                PollManager.Repository.Update(pollInfo);

                return(Ok(new
                {
                    Value = attributeNames
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #4
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var pollInfo = PollManager.GetPollInfo(request);
                if (pollInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(pollInfo.SiteId, PollUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var fieldInfoList = FieldManager.GetFieldInfoList(pollInfo.Id);

                var attributeNames             = PollManager.GetAllAttributeNames(fieldInfoList);
                var administratorSmsNotifyKeys =
                    PollUtils.StringCollectionToStringList(pollInfo.AdministratorSmsNotifyKeys);
                var userSmsNotifyKeys =
                    PollUtils.StringCollectionToStringList(pollInfo.UserSmsNotifyKeys);

                return(Ok(new
                {
                    Value = pollInfo,
                    FieldInfoList = fieldInfoList,
                    AttributeNames = attributeNames,
                    AdministratorSmsNotifyKeys = administratorSmsNotifyKeys,
                    UserSmsNotifyKeys = userSmsNotifyKeys
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }