Exemplo n.º 1
0
 public UserResponse CreateNewUser()
 {
     User res = null;
     string error = null;
     try
     {
         using (var db = new SurveyContext())
         {
             res = User.GenerateNewUser();
             db.SaveUser(res);
         }
     }
     catch (Exception e)
     {
         error = e.Message;
     }
     return new UserResponse(res, error);
 }
Exemplo n.º 2
0
 public string SaveVote(Vote vote)
 {
     try
     {
         if (vote == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.SaveVote(vote);
         }
         return("0");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Exemplo n.º 3
0
 public string DeleteSurvey(Survey survey)
 {
     try
     {
         if (survey == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.DeleteSurvey(survey);
         }
         return("0");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Exemplo n.º 4
0
        public UserResponse CreateNewUser()
        {
            User   res   = null;
            string error = null;

            try
            {
                using (var db = new SurveyContext())
                {
                    res = User.GenerateNewUser();
                    db.SaveUser(res);
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(new UserResponse(res, error));
        }
Exemplo n.º 5
0
 public string SavePanic(Panic panic)
 {
     try
     {
         if (panic == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.SavePanic(panic);
         }
         return("0");
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Exemplo n.º 6
0
        public GetSurveysResponse GetSurveys(string course)
        {
            Survey[] res   = null;
            string   error = null;

            try
            {
                using (var db = new SurveyContext())
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    res = db.getSurveysFor(course);
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(new GetSurveysResponse(res, error));
        }
Exemplo n.º 7
0
 public IntResponse CountPanics(CountPanicsRequest req)
 {
     int res = -1;
     string error = null;
     try
     {
         if (req.Course == null || req.Since == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.Configuration.LazyLoadingEnabled = false;
             db.Configuration.ProxyCreationEnabled = false;
             res = db.CountPanics(req.Course, req.Since);
         }
     }
     catch (Exception e)
     {
         error = e.Message;
     }
     return new IntResponse(res, error);
 }
Exemplo n.º 8
0
        public IntResponse CountLastPanics(CountLastPanicsRequest req)
        {
            int    res   = -1;
            string error = null;

            try
            {
                if (req.Course == null || req.Seconds == null)
                {
                    throw new ArgumentNullException();
                }
                using (var db = new SurveyContext())
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    res = db.CountLastPanics(req.Course, req.Seconds);
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(new IntResponse(res, error));
        }
Exemplo n.º 9
0
        public VoteResponse GetVoteForUser(GetVoteForUserRequest req)
        {
            Vote   vote  = null;
            string error = null;

            try
            {
                if (req.Survey == null || req.User == null)
                {
                    throw new ArgumentNullException();
                }
                using (var db = new SurveyContext())
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    vote = db.GetVoteForUser(req.Survey, req.User);
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(new VoteResponse(vote, error));
        }
Exemplo n.º 10
0
        public GetVoteResultResponse GetVoteResultByID(string surveyID)
        {
            Result[] res   = null;
            string   error = null;

            try
            {
                if (surveyID == null)
                {
                    throw new ArgumentNullException();
                }
                using (var db = new SurveyContext())
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    res = db.getResultsFor(Convert.ToInt32(surveyID));
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }
            return(new GetVoteResultResponse(res, error));
        }
Exemplo n.º 11
0
 public string DeleteSurvey(Survey survey)
 {
     try
     {
         if (survey == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.DeleteSurvey(survey);
         }
         return "0";
     }
     catch (Exception e)
     {
         return e.Message;
     }
 }
Exemplo n.º 12
0
 public string SaveVote(Vote vote)
 {
     try
     {
         if (vote == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.SaveVote(vote);
         }
         return "0";
     }
     catch (Exception e)
     {
         return e.Message;
     }
 }
Exemplo n.º 13
0
 public string SavePanic(Panic panic)
 {
     try
     {
         if (panic == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.SavePanic(panic);
         }
         return "0";
     }
     catch (Exception e)
     {
         return e.Message;
     }
 }
Exemplo n.º 14
0
 public GetVoteResultResponse GetVoteResultByID(string surveyID)
 {
     Result[] res = null;
     string error = null;
     try
     {
         if (surveyID == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.Configuration.LazyLoadingEnabled = false;
             db.Configuration.ProxyCreationEnabled = false;
             res = db.getResultsFor(Convert.ToInt32(surveyID));
         }
     }
     catch (Exception e)
     {
         error = e.Message;
     }
     return new GetVoteResultResponse(res, error);
 }
Exemplo n.º 15
0
 public VoteResponse GetVoteForUser(GetVoteForUserRequest req)
 {
     Vote vote = null;
     string error = null;
     try
     {
         if (req.Survey == null || req.User == null)
         {
             throw new ArgumentNullException();
         }
         using (var db = new SurveyContext())
         {
             db.Configuration.LazyLoadingEnabled = false;
             db.Configuration.ProxyCreationEnabled = false;
             vote = db.GetVoteForUser(req.Survey, req.User);
         }
     }
     catch (Exception e)
     {
         error = e.Message;
     }
     return new VoteResponse(vote, error);
 }
Exemplo n.º 16
0
 public GetSurveysResponse GetSurveys(string course)
 {
     Survey[] res = null;
     string error = null;
     try
     {
         using (var db = new SurveyContext())
         {
             db.Configuration.LazyLoadingEnabled = false;
             db.Configuration.ProxyCreationEnabled = false;
             res = db.getSurveysFor(course);
         }
     }
     catch (Exception e)
     {
         error = e.Message;
     }
     return new GetSurveysResponse(res, error);
 }