Ejemplo n.º 1
0
        public bool CreateResponse(Response response)
        {
            try
            {
                _context.AddToResponses(response);
                _context.SaveChanges();
                return true;
            }
            catch (Exception)
            {

                return false;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Responses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToResponses(Response response)
 {
     base.AddObject("Responses", response);
 }
Ejemplo n.º 3
0
        public ActionResult Index(SurveyViewModel model)
        {
            try
            {
                Entry entry = new Entry();
                entry.SurveyID = model.SurveyId;
                if (User.Identity.Name != "")
                {
                    entry.UserID = User.Identity.Name;
                }
                entry.Date = DateTime.Now;

                int entryid = _repository.CreateEntry(entry);

                foreach (var question in model.Questions)
                {
                    Response r = new Response();
                    r.Date = DateTime.Now;
                    r.Question = question.QuestionId;
                    r.Answer = question.SelectedAnswer;
                    r.Survey = model.SurveyId;
                    r.UserID = User.Identity.Name;
                    r.Entry = entryid;
                    _repository.CreateResponse(r);
                }
            }
            catch (Exception e)
            {
                TempData["Message"] = e;
                return View("Error");
            }

            TempData["Message"] = "Good times.";
            return View("Thanks");
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new Response object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="survey">Initial value of the Survey property.</param>
 /// <param name="question">Initial value of the Question property.</param>
 /// <param name="answer">Initial value of the Answer property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="entry">Initial value of the Entry property.</param>
 public static Response CreateResponse(global::System.Int32 id, global::System.Int32 survey, global::System.Int32 question, global::System.Int32 answer, global::System.DateTime date, global::System.Int32 entry)
 {
     Response response = new Response();
     response.ID = id;
     response.Survey = survey;
     response.Question = question;
     response.Answer = answer;
     response.Date = date;
     response.Entry = entry;
     return response;
 }