/// <summary> /// Concatenates ccg name with deacons last names. /// eg., CCG10 --> CCG10_Bolden_Jones /// </summary> /// <param name="ccg"></param> public string SetCCGViewName(CCG ccg) { string oriCcgName = ccg.CCGName; // To include app users. ccg param does not include them. ccg = unitOfWork.CCGRepository.FindById(ccg.Id); foreach (var deacon in ccg.AppUsers) { ccg.CCGName = ConcatCCGName(ccg.CCGName, deacon.LastName, oriCcgName); } return(ccg.CCGName); }
public ActionResult Create(CCGViewModel ccgViewModel) { if (ModelState.IsValid) { var ccg = new CCG { CCGName = ccgViewModel.CCGName }; unitOfWork.CCGRepository.Add(ccg); return(RedirectToAction("Index")); } return(View(ccgViewModel)); }
private int GetRandomCCGId(UnitOfWork db) { // get random ccgs that have users and members assigned var dbSet = _dbContext.Set <CCG>(); var ccgs = dbSet.Where(g => g.AppUsers.Count > 0 && g.CCGMembers.Count > 0).ToList(); // get random ccg CCG ccg = null; if (ccgs.Count() > 0) { ccg = ccgs.ElementAt(_randomizer.Next(0, ccgs.Count())); } return(ccg != null ? ccg.Id : 0); }