Example #1
0
        public IList <ActivityForumAdminView> GetAllActivities()
        {
            IList <ActivityForum>          allActivities      = _repo.Query <ActivityForum>().ToList();
            IList <ActivityForumAdminView> listableActivities = new List <ActivityForumAdminView>();
            IList <ApplicationUser>        allUsers           = _repo.Query <ApplicationUser>().ToList();

            foreach (ActivityForum activity in allActivities)
            {
                ActivityForumAdminView listable = new ActivityForumAdminView();
                listable.Id          = activity.Id;
                listable.Location    = activity.Location;
                listable.Activity    = activity.Activity;
                listable.Description = activity.Description;
                listable.UserName    = activity.UserName;
                listable.Address     = activity.Address;
                foreach (ApplicationUser user in allUsers)
                {
                    if (user.UserName == activity.UserName)
                    {
                        listable.UserId    = user.Id;
                        listable.UserImage = user.UserImage;
                    }
                }
                listableActivities.Add(listable);
            }
            return(listableActivities);
        }
        public IActionResult AdminSave([FromBody] ActivityForumAdminView activityForumToSave)
        {
            // convert the ActivityForumAdminView back into ActivityForum, pulling out the UserId
            ActivityForum activityForum = new ActivityForum
            {
                Id          = activityForumToSave.Id,
                Location    = activityForumToSave.Location,
                Activity    = activityForumToSave.Activity,
                Description = activityForumToSave.Description,
                UserName    = activityForumToSave.UserName
            };
            string uid = activityForumToSave.UserId;

            _service.SaveActivity(uid, activityForum);
            return(Ok(activityForum));
        }
Example #3
0
        public ActivityForumAdminView GetActivityById(int id)
        {
            IList <ApplicationUser> allUsers         = _repo.Query <ApplicationUser>().ToList();
            ActivityForum           activity         = _repo.Query <ActivityForum>().Where(a => a.Id == id).FirstOrDefault();
            ActivityForumAdminView  viewableActivity = new ActivityForumAdminView();

            viewableActivity.Id          = activity.Id;
            viewableActivity.Location    = activity.Location;
            viewableActivity.Activity    = activity.Activity;
            viewableActivity.Description = activity.Description;
            viewableActivity.UserName    = activity.UserName;
            viewableActivity.Address     = activity.Address;
            foreach (ApplicationUser user in allUsers)
            {
                if (user.UserName == activity.UserName)
                {
                    viewableActivity.UserId = user.Id;
                }
            }
            return(viewableActivity);
        }