示例#1
0
 public ActionResult ObservationDetails(Models.QuestionDetails model)
 {
     using (iobserve.Data.iobserverContext context = new iobserverContext())
     {
         var data = context.Reports.Where(a => a.Id == model.Id).FirstOrDefault();
         data.Remarks = model.Comments;
         //var statusid = context.Captions.Where(a => a.Label_text == model.SelectedStatus).FirstOrDefault().Label_id;
         data.Status_label_id = model.SelectedStatus;
         context.SaveChanges();
     }
     return(RedirectToAction("Dashboard", new { @isReload = true }));
 }
示例#2
0
        //string dd = "ANSWER, PgS1_q1a5, PgS1_q1a4, PgS1_q1a1, PgS1_q1a2, PgS1_q1a3";
        public ActionResult ObservationDetails(string DetailId, string id)
        {
            var lstQ = new List <Models.Question>();
            List <Models.Labels> StatusList = new List <Labels>();


            using (iobserve.Data.iobserverContext context = new iobserverContext())
            {
                var data = System.Web.HttpContext.Current.Session["data"] as List <V_report>;
                //var response = data.Where(a => a.Id == id).FirstOrDefault();
                StatusList = (from label in context.Captions.Where(a => (a.Label_id == LabelIds.PENDING || a.Label_id == LabelIds.REVIEWED || a.Label_id == LabelIds.SUBMITTED) && a.Language_code == "en")
                              select new Models.Labels
                {
                    Label_Id = label.Label_id,
                    Label = label.Label_text
                }).ToList();
                System.Web.HttpContext.Current.Session["StatusList"] = StatusList;
                var statusToUpdate = context.Reports.Where(a => a.Id == id).FirstOrDefault();
                if (statusToUpdate.Status_label_id == LabelIds.SUBMITTED)
                {
                    statusToUpdate.Status_label_id = LabelIds.REVIEWED;
                    context.SaveChanges();
                }
                var response  = context.V_reportsdetails.Where(a => a.Id == id).FirstOrDefault();
                var questions = context.V_questions.Where(a => a.Location_scenario_id == DetailId && a.Language_code == "en").OrderBy(a => a.Seqno).ToList();

                //\q1+\a\d+
                Debug.WriteLine(response);
                Debug.WriteLine("Total questions found : " + questions.Count.ToString());
                questions.ForEach(q =>
                {
                    var question = new iobserve_Azure.Models.Question();

                    question.QuestionText = q.Question_text;
                    var qData             = q.Answer_options_text.Split(new char[] { ';' });
                    question.Type         = q.Answer_format;
                    question.SequenceNo   = q.Seqno.GetValueOrDefault();
                    int ansOptSequenceno  = 1;
                    List <Models.AnswerOptions> optList = new List <Models.AnswerOptions>();

                    qData.ToList().ForEach(ans =>
                    {
                        optList.Add(new Models.AnswerOptions
                        {
                            OptionText = ans,
                            SequenceNo = ansOptSequenceno++
                        });
                    });
                    var wno        = q.Seqno.ToString();
                    string pattern = @"q" + wno + @"a(?<AnsNo>\d+)";
                    var matches    = Regex.Matches(response.Response_array, pattern);
                    if (matches.Count == 0)
                    {
                        Debug.WriteLine("Question no : " + wno + " No match");
                    }
                    foreach (Match m in matches)
                    {
                        var ans = int.Parse(m.Groups["AnsNo"].Value);
                        Models.AnswerOptions cAnsOption = optList.Where(a => a.SequenceNo == ans).FirstOrDefault();
                        if (cAnsOption != null)
                        {
                            cAnsOption.IsSelected = true;
                            Debug.WriteLine("Question No :" + wno.ToString() + " " + "Answer No :" + ans.ToString());
                        }
                    }
                    question.AnswerOptionList = optList;
                    lstQ.Add(question);
                });
                //                [6/22/2014 6:07:52 PM] Faisal Asif: Supervisor notified?
                //Work Stopped? (I am verifying this)
                //Risk Level
                //Cutomer Information
                //Action Taken:
                //supp notified,
                //risk eliminated,
                //notes,
                //status
                return(View(new Models.QuestionDetails {
                    SupervisorNotified = response.Supnotified, RiskEliminated = "YES", Comments = response.Remarks, SelectedStatus = response.Status_text, Questions = lstQ, Image = response.Media_picture_id, Id = response.Id, RiskLevel = response.Risklevel, CustomerInfo = response.Customer, ActionTaken = response.Actiontaken
                }));
            }
        }