protected override void PopulateModel(IndexVM model) { if (!AuthenticationManager.LoggedUser.IsAdmin) { model.Filter.UserId = AuthenticationManager.LoggedUser.Id; } else { UsersRepository uRepo = new UsersRepository(); model.user = uRepo.GetById(model.Filter.UserId); } if (model.Filter.UserId == 0) { model.Filter.UserId = AuthenticationManager.LoggedUser.Id; } ActivitiesRepository aRepo = new ActivitiesRepository(); List <Activity> dbActivities = aRepo.GetAll(a => true); List <SelectListItem> listItems = new List <SelectListItem>(); listItems.Add(new SelectListItem() { Text = "", Value = null }); foreach (Activity activity in dbActivities) { listItems.Add(new SelectListItem() { Text = activity.Name, Value = activity.Id.ToString() }); } model.Filter.activitiesList = new SelectList(listItems, "Value", "Text", model.Filter.ActivityId ?? null); }
//api/activities public IActionResult GetAllActivities() { return(Ok(_repo.GetAll())); }