Beispiel #1
0
        public Error SubmitResponses(SurveyResponseVM vm)
        {
            SuperEarthComEntities1 ctx = new SuperEarthComEntities1();
            Error err = new Error {
                NoError = true, Message = string.Empty
            };

            try
            {
                ctx.SurveyResponses.Add(new SurveyResponse
                {
                    ClientID   = vm.ClientID,
                    SurveyID   = vm.SurveyID,
                    Responses  = vm.ResponseString,
                    CreateDate = DateTime.Now
                });
                ctx.SaveChanges();
            }
            catch (Exception ex)
            {
                err.NoError = false;
                err.Message = ex.Message;
            }

            return(err);
        }
        public bool ProcessSurveyResponses(int clientid, int surveyid, string responses)
        {
            bool             didProcess = true;
            string           path       = Server.MapPath("~/logs/log.txt");
            string           reqPath    = Server.MapPath("~/logs/request.txt");
            SurveyRepo       repo       = new SurveyRepo();
            SurveyResponseVM vm         = new SurveyResponseVM {
                ClientID = clientid, SurveyID = surveyid, ResponseString = responses
            };

            try
            {
                repo.SubmitResponses(vm);
            }
            catch (Exception ex)
            {
                using (StreamWriter writer = new StreamWriter(path, true))
                {
                    writer.WriteLine(string.Concat(DateTime.Now.ToLongDateString(), " :", ex.Message));
                    didProcess = false;
                }
            }


            return(didProcess);
        }