//Methods for this controller //************************************************************ //Returns a view with ChoreDoerModel if all checks pass private ActionResult ViewDoerById(int?id) { //Check for Id if (id == null) { NullIdEncountered(); } using (var context = new RotatingChoresContext()) { var doer = GetDoerById(id, context); //Check for Doer in the database if (doer != null) { //Check that ChoreDoer is part of user's group if (IsGroupObject(doer.GroupId)) { var userGroup = GetUserGroup(context); var doerModel = ChoreDoerModel.ConvertFromDoer(doer); doerModel.AddChoresList(doer, userGroup); return(View(doerModel)); } return(InvalidGroup()); } return(DoerNotFound()); } }
private void SetGroupMemberSelectList(RotatingChoresContext context) { var returnList = new List <ChoreDoerModel>(); Group userGroup = GetUserGroup(context); if (userGroup.Members.Count() > 0) { foreach (var member in userGroup.Members) { returnList.Add(ChoreDoerModel.ConvertFromDoer(member)); } } var selectList = new SelectList(returnList, "ChoreDoerId", "Name"); ViewBag.GroupMembers = selectList; }
// GET: Doer public ActionResult Index() { using (var context = new RotatingChoresContext()) { var group = GetUserGroup(context); var modelList = new List <ChoreDoerModel>(); if (group.Members.Count > 0) { foreach (var doer in group.Members) { var doerModel = ChoreDoerModel.ConvertFromDoer(doer); doerModel.AddChoresList(doer, group); modelList.Add(doerModel); } return(View(modelList)); } TempData["Message"] = "No group members. Add one now!"; return(RedirectToAction("Add")); } }