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); }
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)); } }