public List <UserVM> GetUsersByEventId(int id) { List <User> users = mysticoContext.GetUsersByEventId(id); List <UserVM> userVMs = Library.ConvertUsersToUsersVM(users); return(userVMs); }
public async Task <IActionResult> Overview(int id) { var myUser = await userManager.GetUserAsync(HttpContext.User); User user = mysticoContext.GetUserByAspUserId(myUser.Id); if (mysticoContext.CheckIfUserIsParticipant(user.Id, id) == false) { return(RedirectToAction(nameof(SplitController.Index), nameof(SplitController).Replace("Controller", ""))); } var thisEvent = mysticoContext.GetEventById(id); var transactions = Library.WhoOweWho(thisEvent); var transactionsVM = Library.ConvertWhoOwesWho(transactions); var myTransactions = new List <WhoOwesWhoVM>(); var restTransactions = new List <WhoOwesWhoVM>(); foreach (var item in transactionsVM) { if (item.DebitorId == user.Id || item.CreditorId == user.Id) { myTransactions.Add(item); } else { restTransactions.Add(item); } } List <UserVM> participants = Library.ConvertUsersToUsersVM(mysticoContext.GetUsersByEventId(thisEvent.Id)); var viewModel = new SplitOverviewVM() { TransactionsCommittedToMe = myTransactions, TransactionsWithoutMe = restTransactions, EventName = thisEvent.EventName, MyStatus = Library.GetUserStatusById(thisEvent, user.Id), MyTotal = Library.GetUserTotalById(thisEvent, user.Id), Total = Library.GetTotalCostForEvent(thisEvent), EventIsActive = thisEvent.IsActive, EventId = id, StandardCurrency = thisEvent.StandardCurrency.CurrencyCode, AlreadyParticipants = participants }; return(View(viewModel)); }