public ActionResult List(int id, int questionnaireId = 1)
        {
            var vmVerificationItems = new VmVerificationItems {
                VerificationItems = new Collection <VmVerificationItem>()
            };

            var userVerificationRecords = _db.Verifications.Where(x => x.UserId == id && x.QuestionnaireId == questionnaireId).ToList();

            var latticeItems    = _db.LatticeItems.ToList();
            var selectListItems = latticeItems.Select(latticeItem => new SelectListItem
            {
                Text = latticeItem.DropdownText, Value = latticeItem.DropdownText
            }).ToList();

            vmVerificationItems.LatticeItems = selectListItems;

            foreach (var userVerificationRecord in userVerificationRecords)
            {
                var record             = userVerificationRecord;
                var vmVerificationItem = new VmVerificationItem
                {
                    Verification = record,
                    Files        = _db.Files.Where(
                        x =>
                        x.UserId == id && x.QuestionnaireId == questionnaireId &&
                        x.QuestionnaireQCategoryId == record.QCategoryId &&
                        x.QCategorySubOrdinal == record.SubOrdinal).ToList()
                };

                vmVerificationItems.VerificationItems.Add(vmVerificationItem);
            }

            return(View(vmVerificationItems));
        }
        public ActionResult List(int id, int questionnaireId = 1)
        {
            var vmVerificationItems = new VmVerificationItems()
            {
                VerificationItems = new Collection <VmVerificationItem>()
            };

            var userVerificationRecords = _db.Verifications.Where(x => x.UserId == id && x.QuestionnaireId == questionnaireId).ToList();

            var levelCheck = _db.UserLevels.Any(x => x.UserId == id);

            if (_db.UserLevels.Any(x => x.UserId == id) == false)
            {
                var uL = new UserLevel {
                    UserId = id, FinalStepLevel = "none", FinalStepLevelDate = DateTime.Today
                };
                _db.UserLevels.Add(uL);
                _db.SaveChanges();
            }

            var userLevel = _db.UserLevels.Where(x => x.UserId == id).SingleOrDefault();

            vmVerificationItems.UserLevel = userLevel;


            var latticeItems    = _db.LatticeItems.ToList();
            var selectListItems = latticeItems.Select(latticeItem => new SelectListItem
            {
                Text = latticeItem.DropdownText, Value = latticeItem.DropdownText
            }).ToList();

            vmVerificationItems.LatticeItems = selectListItems;

            foreach (var userVerificationRecord in userVerificationRecords)
            {
                var record             = userVerificationRecord;
                var vmVerificationItem = new VmVerificationItem
                {
                    Verification = record,
                    Files        = _db.Files.Where(
                        x =>
                        x.UserId == id && x.QuestionnaireId == questionnaireId &&
                        x.QuestionnaireQCategoryId == record.QCategoryId &&
                        x.QCategorySubOrdinal == record.SubOrdinal).ToList()
                };

                vmVerificationItems.VerificationItems.Add(vmVerificationItem);
            }

            return(View(vmVerificationItems));
        }
 public ActionResult Edit(VmVerificationItem item)
 {
     try
     {
         // TODO: Add update logic here
         _db.Entry(item.Verification).State = (EntityState)System.Data.Entity.EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("List", new { id = item.Verification.UserId }));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Edit(int id)
        {
            var vmVerificationItems = new VmVerificationItems {
                VerificationItems = new Collection <VmVerificationItem>()
            };

            var userVerificationRecords = _db.Verifications.Where(x => x.Id == id).ToList();

            var questionnaireId = userVerificationRecords.First().QuestionnaireId;

            var userGuid = new Guid(User.Identity.GetUserId()); //WebSecurity.GetUserId(User.Identity.Name);
            var userId   = BitConverter.ToInt32(userGuid.ToByteArray(), 0);

            var latticeItems    = _db.LatticeItems.ToList();
            var selectListItems = new List <SelectListItem>();

            foreach (var latticeItem in latticeItems)
            {
                var selectListItem = new SelectListItem
                {
                    Text  = latticeItem.DropdownText,
                    Value = latticeItem.DropdownText
                };
                selectListItems.Add(selectListItem);
            }
            vmVerificationItems.LatticeItems = selectListItems;

            foreach (var userVerificationRecord in userVerificationRecords)
            {
                var record             = userVerificationRecord;
                var vmVerificationItem = new VmVerificationItem
                {
                    Verification = record,
                    Files        = _db.Files.Where(
                        x =>
                        x.UserId == userId && x.QuestionnaireId == questionnaireId &&
                        x.QuestionnaireQCategoryId == record.QCategoryId &&
                        x.QCategorySubOrdinal == record.SubOrdinal).ToList()
                };

                vmVerificationItems.VerificationItems.Add(vmVerificationItem);
            }

            return(View(vmVerificationItems));
        }