Example #1
0
        public ActionResult ShowReport(int ownerId, int checklistId)
        {
            OwnedChecklistVM model = new OwnedChecklistVM();

            model.Owner = db.Owners.Find(ownerId);

            model.Checklist = db.Checklists.Find(checklistId);

            foreach (ChecklistItem item in model.Checklist.Items)
            {
                item.isChecked = model.Owner.CheckedItems.Contains(item);
            }

            return View(model);
        }
Example #2
0
        public PartialViewResult GetOwnedChecklist(int ownerId, int checklistId)
        {
            OwnedChecklistVM model = new OwnedChecklistVM();

            model.Owner = db.Owners.Find(ownerId);

            model.Checklist = db.Checklists.Find(checklistId);

            foreach (ChecklistItem item in model.Checklist.Items)
            {
                item.isChecked = model.Owner.CheckedItems.Contains(item);
            }

            return PartialView("_OwnedChecklist", model);
        }
Example #3
0
        public ActionResult Index()
        {
            OwnedChecklistVM model = new OwnedChecklistVM();

            model.Owners = db.Owners.AsEnumerable().Select(o =>
                                new SelectListItem
                                {
                                    Text = o.Name,
                                    Value = o.Id.ToString()
                                });

            model.Checklists = db.Checklists.AsEnumerable().Select(c =>
                                new SelectListItem
                                {
                                    Text = c.Title,
                                    Value = c.Id.ToString()
                                });

            return View(model);
        }
Example #4
0
        public ActionResult UpdateOwnedChecklist(OwnedChecklistVM model)
        {
            Owner updatedOwner = db.Owners.Find(model.Owner.Id);
            updatedOwner.Credits = model.Owner.Credits;

            List<ChecklistItem> dbItems = db.Checklists.Find(model.Checklist.Id).Items.ToList();

            foreach (ChecklistItem item in model.Checklist.Items)
            {
                if (item.isChecked)
                {
                    updatedOwner.CheckedItems.Add(dbItems.Find(i => i.Id == item.Id));
                }
                else
                {
                    updatedOwner.CheckedItems.Remove(dbItems.Find(i => i.Id == item.Id));
                }
            }

            db.SaveChanges();

            return View();
        }