public async Task <List <Event> > GetAll()
        {
            var(start, count) = ParseGetAllHeaders(Request.Headers);

            User currentUser = await UserRetrievingService.GetByUserName(User.Identity.Name);

            int cityId = currentUser.Location.City.Id;

            return(await EventRetrievingService.GetBatchSortedByLocation(cityId, start, count));
        }
        public async Task <ProfileModel> GetUserProfile(Guid userId)
        {
            ProfileUser user = await UserRetrievingService.GetById(userId);

            ProfileModel profile = Mapper.Map <ProfileUser, ProfileModel>(user);

            SetIsSelf(profile);

            return(profile);
        }
        public IHttpActionResult GetUsersProfiles()
        {
            IEnumerable <ProfileUser> users = UserRetrievingService.GetAll();

            List <ProfileModel> profiles = users.Select(Mapper.Map <ProfileModel>).ToList();

            ProfileModel selfProfile = profiles.First(p => p.UserName == User.Identity.Name);

            selfProfile.IsSelf = true;

            return(Ok(profiles));
        }
        public async Task <ProfileModel> Edit([FromBody] ProfileModel editModel)
        {
            ProfileUser user = await UserRetrievingService.GetByUserName(User.Identity.Name);

            if (editModel.Id != user.Id)
            {
                throw new InvalidOperationException("You cannot edit current profile");
            }

            ProfileUser editedUser = Mapper.Map(editModel, user);

            await UserManager.UpdateAsync(editedUser);

            return(editModel);
        }
        public async Task UnsubscribeFromEvent([FromUri] Guid eventId)
        {
            User currentUser = await UserRetrievingService.GetByUserName(User.Identity.Name);

            await SubscribeOnEventService.Unsubscribe(currentUser.Id, eventId);
        }