private void SentEmail(List <NotificationViewModel> n) { UpdateList(); foreach (var item in listNotification) { if (AccountController.CheckUser(item.FromId) && item.SenderDeleted == false) { n.Add(item); } } }
public JsonResult SaveAnswers(string answer, string answers, string questionid, string ipaddress, string browser) { List <QuestionAnswerViewModel> q = AccountController.GetQuestionAnswer(); RespondentViewModel r = AccountController.GetRespondent(); if (r == null) { r = new RespondentViewModel(); r.Id = Guid.NewGuid(); if (AccountController.CheckUser()) { r.UserId = AccountController.GetUser().Id; r.IsRegistered = true; } r.IPAdress = ipaddress; r.BrowserName = browser; r.SurveyId = AccountController.GetSurveyId(); } //q.Add(new QuestionViewModel{Id = new Guid(questionid)}); //int i = r.Count - 1; if (r.Responses == null) { r.Responses = new List <ResponseViewModel>(); } if (q == null) { q = new List <QuestionAnswerViewModel>(); } if (answer != null) { QuestionAnswerViewModel qa = new QuestionAnswerViewModel { Id = Guid.NewGuid(), QuestionId = new Guid(questionid), Answer = answer }; q.Add(qa); AccountController.RememberQuestionAnswer(q); ResponseViewModel rs = new ResponseViewModel { Id = Guid.NewGuid(), QuestionId = new Guid(questionid), ResponseAnswer = qa.Id, RespondentId = r.Id }; r.Responses.Add(rs); } else if (answers != "") { string[] a = answers.Split(','); //UpdateList(); //var type = listQuestion.Find(x=>x.Id==new Guid(questionid)).Type; //if (type == "Yes/No") //{ // answers = new List<string>(); //} foreach (var item in a) { if (item != "") { ResponseViewModel rs = new ResponseViewModel { Id = Guid.NewGuid(), QuestionId = new Guid(questionid), ResponseAnswer = new Guid(item), RespondentId = r.Id }; r.Responses.Add(rs); } } } AccountController.RememberRespondent(r); return(Json(true, JsonRequestBehavior.AllowGet)); }