Esempio n. 1
0
        public HttpResponseMessage ExportExternalAnswersToExcel(int formId)
        {
            HttpResponseMessage       response     = new HttpResponseMessage(HttpStatusCode.OK);
            UserPrincipal             loggedInUser = (UserPrincipal)HttpContext.Current.User;
            List <ExternalFormSubmit> submits      = ExternalFormSubmit.MapExternalFormSubmits(
                FormsAdminBLL.GetExternalSubmits(formId, loggedInUser.AccountSession.ClubId));

            DataTable dt = new DataTable();

            foreach (var item in submits)
            {
                string[] values  = new string[item.FormSubmits.Count];
                int      counter = 0;
                foreach (var submit in item.FormSubmits)
                {
                    if (!dt.Columns.Contains(submit.Name))
                    {
                        dt.Columns.Add(new DataColumn(submit.Name, typeof(string)));
                    }

                    values[counter] = submit.Value;
                    counter++;
                }

                dt.Rows.Add(values);
            }
            var form = FormsAdminBLL.GetForm(formId, loggedInUser.AccountSession.ClubId);

            response.Content = new ObjectContent <string>(ExcelHelper.CreateExcelDocument(dt, form.Name, true, "Forms"), new JsonMediaTypeFormatter());
            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage GetExternalAnswers(int formId)
        {
            HttpResponseMessage response     = new HttpResponseMessage(HttpStatusCode.OK);
            UserPrincipal       loggedInUser = (UserPrincipal)HttpContext.Current.User;

            response.Content = new ObjectContent <List <ExternalFormSubmit> >(ExternalFormSubmit.MapExternalFormSubmits(
                                                                                  FormsAdminBLL.GetExternalSubmits(formId, loggedInUser.AccountSession.ClubId)),
                                                                              new JsonMediaTypeFormatter());
            return(response);
        }