public async Task <ApiResult <ApplicationUserType> > Login(string username, string password) { return(await ApiRequestHelper.HandlApiRequest(async() => { var token = await _api.GetTokenByPassword(new OfflineFlowRequest(username, password)); Settings.ApplicationData.RefreshToken = token.RefreshToken; Settings.ApplicationData.AccessToken = token.AccessToken; Settings.ApplicationData.TokenExpireTime = DateTimeOffset.Now.Subtract(new TimeSpan(0, 0, token.ExpiresIn)); var result = await GetCurrentApplicationUser(); if (!result.Success) { return result; } if (result.Result == ApplicationUserType.Admin && Settings.ApplicationData.CurrentAdminViewModel != null) { await InitializeAdminViewModel(username); } else if (Settings.ApplicationData.CurrentUserViewModel != null) { await InitializeUserViewModel(username); } return result; })); }
public async Task <ApiResult> BlockUser(Guid accountId, string reason) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.BlockUser(accountId, AccountModel.BlockUser(reason)); return new ApiResult(string.Empty, true); })); }
public async Task <ApiResult <IEnumerable <BaseChatViewModel> > > GetNewChats(DateTimeOffset date, int numberToTake) { return(await ApiRequestHelper.HandlApiRequest(async() => { var chats = await _api.GetNewChats(date.ToString("O"), numberToTake); return new ApiResult <IEnumerable <BaseChatViewModel> >(string.Empty, true, chats.Select(c => new BaseChatViewModel(c))); })); }
public async Task <ApiResult <BaseChatViewModel> > GetChatByAnotherUser(Guid userId) { return(await ApiRequestHelper.HandlApiRequest(async() => { var chat = await _api.GetChatByAnotherUser(userId); return new ApiResult <BaseChatViewModel>(string.Empty, true, chat == null ? null : new BaseChatViewModel(chat)); })); }
public async Task <ApiResult> DeleteCity(Guid id) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.DeleteCity(id); return new ApiResult(string.Empty, true); })); }
public async Task <ApiResult <IEnumerable <BaseCityViewModel> > > GetAllCities() { return(await ApiRequestHelper.HandlApiRequest(async() => { var cities = await _api.GetAllCities(); return new ApiResult <IEnumerable <BaseCityViewModel> >(string.Empty, true, cities.Select(c => new BaseCityViewModel(c))); })); }
public async Task <ApiResult <BaseAdminViewModel> > GetAdmin() { return(await ApiRequestHelper.HandlApiRequest(async() => { var admin = await _api.GetAdmin(); return new ApiResult <BaseAdminViewModel>(string.Empty, true, new BaseAdminViewModel(admin)); })); }
public async Task <ApiResult <BasePostViewModel> > UpdatePost(BasePostViewModel post) { return(await ApiRequestHelper.HandlApiRequest(async() => { var newPost = await _api.UpdatePost(Mapper.Map <Post>(post)); return new ApiResult <BasePostViewModel>(string.Empty, true, new BasePostViewModel(newPost)); })); }
public async Task <ApiResult> ReportUser(BaseUserReportViewModel model) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.ReportUser(Mapper.Map <UserReport>(model)); return new ApiResult(string.Empty, true); })); }
public async Task <ApiResult <IEnumerable <BaseUserReportViewModel> > > GetAllProcessedUserReports(int numberPerPage, DateTimeOffset oldestReport) { return(await ApiRequestHelper.HandlApiRequest(async() => { var userReports = await _api.GetAllProcessedUserReportsPart(numberPerPage, oldestReport); return new ApiResult <IEnumerable <BaseUserReportViewModel> >(string.Empty, true, userReports.Select(u => new BaseUserReportViewModel(u))); })); }
public async Task <ApiResult <IEnumerable <BaseUserReportViewModel> > > GetAllProcessedUserReports() { return(await ApiRequestHelper.HandlApiRequest(async() => { var userReports = await _api.GetAllProcessedUserReports(); return new ApiResult <IEnumerable <BaseUserReportViewModel> >(string.Empty, true, userReports.Select(u => new BaseUserReportViewModel(u))); })); }
public async Task <ApiResult <BaseNeighborhoodViewModel> > GetNeighborhood(Guid id) { return(await ApiRequestHelper.HandlApiRequest(async() => { var neighborhood = await _api.GetNeighborhood(id); return new ApiResult <BaseNeighborhoodViewModel>(string.Empty, true, new BaseNeighborhoodViewModel(neighborhood)); })); }
public async Task <ApiResult <IEnumerable <BaseNeighborhoodViewModel> > > GetAllNeighborhoods() { return(await ApiRequestHelper.HandlApiRequest(async() => { var neighborhoods = await _api.GetAllNeighborhoods(); return new ApiResult <IEnumerable <BaseNeighborhoodViewModel> >(string.Empty, true, neighborhoods.Select(c => new BaseNeighborhoodViewModel(c))); })); }
public async Task <ApiResult> ResendConfirmationEmail(string emailAdress) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.ResendConfirmationEmail(emailAdress); return new ApiResult(string.Empty, true); })); }
public async Task <ApiResult> UnblockUser(Guid accountId) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.UnblockUser(accountId); return new ApiResult(string.Empty, true); })); }
public async Task <ApiResult <IEnumerable <BasePostViewModel> > > GetPosts(Guid userId, string keyword) { return(await ApiRequestHelper.HandlApiRequest(async() => { var posts = await _api.GetPosts(userId, keyword); return new ApiResult <IEnumerable <BasePostViewModel> >(string.Empty, true, posts.Select(p => new BasePostViewModel(p))); })); }
public async Task <ApiResult <IEnumerable <BasePostViewModel> > > GetPosts(Guid userId, DateTimeOffset date, int numberToTake, string keyword) { return(await ApiRequestHelper.HandlApiRequest(async() => { var posts = await _api.GetPostsPart(userId, date.ToString("O"), numberToTake, keyword); return new ApiResult <IEnumerable <BasePostViewModel> >(string.Empty, true, posts.Select(p => new BasePostViewModel(p))); })); }
public async Task <ApiResult <BaseUserReportViewModel> > ProcessReport(BaseUserReportViewModel model) { return(await ApiRequestHelper.HandlApiRequest(async() => { var userReport = await _api.ProcessReport(Mapper.Map <UserReport>(model)); return new ApiResult <BaseUserReportViewModel>(string.Empty, true, new BaseUserReportViewModel(userReport)); })); }
public async Task <ApiResult <BasePostViewModel> > LikeOrDislike(Guid postId) { return(await ApiRequestHelper.HandlApiRequest(async() => { var newPost = await _api.LikeOrDislike(postId); return new ApiResult <BasePostViewModel>(string.Empty, true, new BasePostViewModel(newPost)); })); }
public async Task <ApiResult <IEnumerable <BaseProfileCommentViewModel> > > GetAllCommentsForUser(Guid userId) { return(await ApiRequestHelper.HandlApiRequest(async() => { var commentForProfiles = await _api.GetAllCommentsForUser(userId); return new ApiResult <IEnumerable <BaseProfileCommentViewModel> >(string.Empty, true, commentForProfiles.Select(c => new BaseProfileCommentViewModel(c))); })); }
public async Task <ApiResult <BaseAdminViewModel> > CreateAdmin(BaseAdminViewModel admin) { return(await ApiRequestHelper.HandlApiRequest(async() => { var newAdmin = await _api.CreateAdmin(Mapper.Map <Admin>(admin)); return new ApiResult <BaseAdminViewModel>(string.Empty, true, new BaseAdminViewModel(newAdmin)); })); }
public async Task <ApiResult <BasePostCommentViewModel> > GetPostComment(Guid id) { return(await ApiRequestHelper.HandlApiRequest(async() => { var commentForPost = await _api.GetPostComment(id); return new ApiResult <BasePostCommentViewModel>(string.Empty, true, new BasePostCommentViewModel(commentForPost)); })); }
public async Task <ApiResult <BaseCityViewModel> > CreateOrUpdateCity(BaseCityViewModel city) { return(await ApiRequestHelper.HandlApiRequest(async() => { var newCity = await _api.CreateOrUpdateCity(Mapper.Map <City>(city)); return new ApiResult <BaseCityViewModel>(string.Empty, true, new BaseCityViewModel(newCity)); })); }
public async Task <ApiResult <IEnumerable <BasePostCommentViewModel> > > GetAllPostComments(Guid postId) { return(await ApiRequestHelper.HandlApiRequest(async() => { var commentForPosts = await _api.GetAllPostComments(postId); return new ApiResult <IEnumerable <BasePostCommentViewModel> >(string.Empty, true, commentForPosts.Select(c => new BasePostCommentViewModel(c))); })); }
public async Task <ApiResult <BaseChatViewModel> > GetChat(Guid id) { return(await ApiRequestHelper.HandlApiRequest(async() => { var chat = await _api.GetChat(id); return new ApiResult <BaseChatViewModel>(string.Empty, true, new BaseChatViewModel(chat)); })); }
public async Task <ApiResult <IEnumerable <BasePostCommentViewModel> > > GetAllPostComments(Guid id, DateTimeOffset date, int numberToTake) { return(await ApiRequestHelper.HandlApiRequest(async() => { var commentForPosts = await _api.GetAllPostCommentsPart(id, date.ToString("O"), numberToTake); return new ApiResult <IEnumerable <BasePostCommentViewModel> >(string.Empty, true, commentForPosts.Select(c => new BasePostCommentViewModel(c))); })); }
public async Task <ApiResult <IEnumerable <BaseChatViewModel> > > GetChats(string keyword) { return(await ApiRequestHelper.HandlApiRequest(async() => { var chats = await _api.GetChatsByKeyword(keyword); return new ApiResult <IEnumerable <BaseChatViewModel> >(string.Empty, true, chats.Select(c => new BaseChatViewModel(c))); })); }
public async Task <ApiResult <BasePostCommentViewModel> > CreatePostComment(BasePostCommentViewModel comment) { return(await ApiRequestHelper.HandlApiRequest(async() => { var commentForPost = await _api.CreatePostComment(Mapper.Map <PostComment>(comment)); return new ApiResult <BasePostCommentViewModel>(string.Empty, true, new BasePostCommentViewModel(commentForPost)); })); }
public async Task <ApiResult <BaseChatViewModel> > CreateChat(BaseChatViewModel chat) { return(await ApiRequestHelper.HandlApiRequest(async() => { var newChat = await _api.CreateChat(Mapper.Map <Chat>(chat)); return new ApiResult <BaseChatViewModel>(string.Empty, true, new BaseChatViewModel(newChat)); })); }
public async Task <ApiResult> DeletePicture(string filename) { return(await ApiRequestHelper.HandlApiRequest(async() => { await _api.DeletePicture(filename); return new ApiResult(string.Empty, true); })); }