public async Task<IActionResult> Info(EditInfoPostData postData) { string memberID = this.HttpContext.Session.GetObject<string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { MemberDto memberDto = new MemberDto() { MemberID = memberID, Birthday = postData.Birthday, BodyHeight = postData.BodyHeight, BodyWeight = postData.BodyWeight, Gender = postData.Gender, FrontCoverUrl = postData.FrontCoverUrl, PhotoUrl = postData.PhotoUrl }; ResponseResultDto responseResult = await this.memberService.EditData(memberDto); if (responseResult.Ok) { return Ok(responseResult.Data); } return BadRequest(responseResult.Data); } catch (Exception ex) { this.logger.LogError($"Edit Data For Info Error >>> MemberID:{memberID} PostData:{JsonConvert.SerializeObject(postData)}\n{ex}"); return BadRequest("會員編輯發生錯誤."); } }
public async Task <IActionResult> Get() { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamDto teamDto = new TeamDto() { ExecutorID = memberID }; ResponseResultDto responseResult = await this.teamService.GetTeamDataListOfMember(teamDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Get Team List Of Member Error >>> ExecutorID:{memberID}\n{ex}"); return(BadRequest("取得會員的車隊資料列表發生錯誤.")); } }
public ResponseResultDto <CategoryDto> GetById(int id) { ResponseResultDto <CategoryDto> result = new ResponseResultDto <CategoryDto>(); try { var entity = this.cateRepository.Query(p => p.Id == id).FirstOrDefault(); if (null == entity) { result.ErrorMessage = "记录不存在或已删除"; } else { result.Result = new CategoryDto() { Id = entity.Id, Name = entity.Name, Remark = entity.Remark }; result.IsSuccess = true; } } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误"; } return(result); }
public async Task <IActionResult> ResetPassword(ForgetPasswordVerifierPostData postData) { try { bool isValidVerifierCode = await this.verifierService.IsValidVerifierCode(VerifierType.ForgetPassword.ToString(), postData.Email, postData.VerifierCode); if (!isValidVerifierCode) { return(BadRequest("驗證碼驗證失敗.")); } ResponseResultDto responseResult = await this.memberService.ResetPassword(postData.Email); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Reset Password Error >>> Email:{postData.Email} VerifierCode:{postData.VerifierCode}\n{ex}"); return(BadRequest("會員重設密碼發生錯誤.")); } }
public async Task <IActionResult> Create(CreateTeamEventPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamEventDto teamEventDto = new TeamEventDto() { TeamID = postData.TeamID, MemberID = memberID, Altitude = postData.Altitude, Distance = postData.Distance, EventDate = postData.EventDate, Title = postData.Title }; ResponseResultDto responseResult = await this.teamService.CreateTeamEventData(teamEventDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Create Team Event Data Error >>> MemberID:{memberID} Data:{JsonConvert.SerializeObject(postData)}\n{ex}"); return(BadRequest("建立車隊活動資料發生錯誤.")); } }
public async Task <IActionResult> Post(RideDataPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { RideDto rideDto = new RideDto() { MemberID = memberID, Climb = postData.Climb, Content = postData.Content, CityID = postData.CityID, Distance = postData.Distance, Level = postData.Level, RideTime = postData.RideTime, Title = postData.Title }; ResponseResultDto responseResult = await this.memberService.AddRideData(rideDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Add Ride Data Error >>> MemberID:{memberID} PostData:{JsonConvert.SerializeObject(postData)}\n{ex}"); return(BadRequest("新增騎乘資料發生錯誤.")); } }
public async Task <IActionResult> Post(SearchTeamPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamDto teamDto = new TeamDto() { SearchKey = postData.SearchKey, ExecutorID = memberID }; ResponseResultDto responseResult = await this.teamService.SearchTeam(teamDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Search Team Error >>> ExecutorID:{memberID} SearchKey:{postData.SearchKey}\n{ex}"); return(BadRequest("搜尋車隊發生錯誤.")); } }
public ResponseResultDto <bool> DeleteCategory(List <int> idList) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { var entities = this.cateRepository.Query(p => idList.Contains(p.Id)).ToList(); if (null != entities && entities.Count > 0) { int count = this.articleRepository.Query(p => idList.Contains(p.CategoryId)).Count(); if (count > 0) { result.IsSuccess = false; result.ErrorMessage = "当前所选分类中,尚存在部分分类下有所属留言,请先删除所有相关联的留言"; } else { this.cateRepository.Delete(entities); result.IsSuccess = this.cateRepository.SaveChanged() > 0; } } else { result.IsSuccess = false; result.ErrorMessage = "记录不存在或已删除"; } result.Result = result.IsSuccess; } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误,请稍后重试"; } return(result); }
public ResponseResultDto <PagedResultDto <CategoryDto> > GetList(string name, int page, int pageSize) { ResponseResultDto <PagedResultDto <CategoryDto> > result = new ResponseResultDto <PagedResultDto <CategoryDto> >(); try { var query = this.cateRepository.Query(); if (!string.IsNullOrWhiteSpace(name)) { query = query.Where(p => p.Name.Contains(name)); } page = page <= 0 ? 1 : page; pageSize = pageSize <= 0 || pageSize > 100 ? 10 : pageSize; result.Result = new PagedResultDto <CategoryDto>(); result.Result.Total = query.Count(); result.Result.Page = page; result.Result.PageSize = pageSize; result.Result.Results = query.OrderBy(p => p.Name).Skip((page - 1) * pageSize).Take(pageSize).Select(p => new CategoryDto { Id = p.Id, Name = p.Name, Remark = p.Remark }).ToList(); result.IsSuccess = true; } catch (Exception ex) { log.LogError(ex, "发生错误"); result.IsSuccess = false; result.ErrorMessage = "服务错误,请稍后重试"; } return(result); }
public ResponseResultDto <bool> UpdateCategory(CategoryDto category) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { int count = this.cateRepository.Query(p => p.Id == category.Id).Count(); if (count <= 0) { result.ErrorMessage = "记录不存在或已删除"; } else { CategoryEntity entity = new CategoryEntity() { Id = category.Id, Name = category.Name, Remark = category.Remark }; this.cateRepository.Update(entity); result.IsSuccess = this.cateRepository.SaveChanged() > 0; result.Result = result.IsSuccess; } } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误"; } return(result); }
public ResponseResultDto <bool> DeleteCategory(int id) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { var entity = this.cateRepository.Query(p => p.Id == id).FirstOrDefault(); if (null != entity) { int count = this.articleRepository.Query(p => p.CategoryId == id).Count(); if (count > 0) { result.IsSuccess = false; result.ErrorMessage = "该分类下尚存在留言,请先删除该分类下的所有留言"; } else { this.cateRepository.Delete(entity); result.IsSuccess = this.cateRepository.SaveChanged() > 0; } } else { result.IsSuccess = false; result.ErrorMessage = "记录不存在或已删除"; } result.Result = result.IsSuccess; } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误,请稍后重试"; } return(result); }
public async Task <IActionResult> SearchFriend(SearchFriendPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { InteractiveDto interactiveDto = new InteractiveDto() { MemberID = memberID, SearchKey = postData.Email }; ResponseResultDto responseResult = await this.memberService.SearchFriend(interactiveDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Search Friend Error >>> MemberID:{memberID} Email:{postData.Email}\n{ex}"); return(BadRequest("搜尋好友發生錯誤.")); } }
public async Task <IActionResult> ForgotPassword(string userID) { ResponseResultDto res = new ResponseResultDto(); if (userID != null) { // check if there's an user with the given username var user = await uow.AccountRepository.GetUserByUserID(userID); // Validate user if (user != null) { bool isMailsent = await uow.AccountRepository.SendEmailToUserForgotPwd(user); if (isMailsent) { res.MessageType = MessageConstant.Success; res.Message = MessageConstant.PasswordSentToEmailID; } else { res.MessageType = MessageConstant.Error; res.Message = MessageConstant.EnterUserID; } } else { res.Message = MessageConstant.Error; res.Message = MessageConstant.EnterUserID; } } return(Ok(new { ResponseResult = res })); }
public async Task <IActionResult> RemoveBlack(RemoveBlackPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { InteractiveDto interactiveDto = new InteractiveDto() { MemberID = memberID, InteractiveID = postData.MemberID }; ResponseResultDto responseResult = await this.memberService.RemoveBlack(interactiveDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Remove Black Error >>> MemberID:{memberID} InteractiveID:{postData.MemberID}\n{ex}"); return(BadRequest("移除黑名單發生錯誤.")); } }
public async Task <IActionResult> AgreeInvite(AgreeInvitePostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamDto teamDto = new TeamDto() { TeamID = postData.TeamID, ExecutorID = memberID }; ResponseResultDto responseResult = await this.teamService.AgreeInviteJoinTeam(teamDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Agree Invite For Join Team Error >>> TeamID:{postData.TeamID} ExecutorID:{memberID}\n{ex}"); return(BadRequest("同意邀請加入車隊發生錯誤.")); } }
public async Task <IActionResult> Delete(DeleteTeamEventPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamEventDto teamEventDto = new TeamEventDto() { TeamID = postData.TeamID, MemberID = memberID, EventID = postData.EventID }; ResponseResultDto responseResult = await this.teamService.DeleteTeamEventData(teamEventDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Delete Team Event Data Error >>> TeamID:{postData.TeamID} EventID:{postData.EventID} MemberID:{memberID}\n{ex}"); return(BadRequest("刪除車隊活動資料發生錯誤.")); } }
public async Task <IActionResult> Bind(MobileBindVerifierPostData postData) { try { bool isValidVerifierCode = await this.verifierService.IsValidVerifierCode(VerifierType.MobileBind.ToString(), postData.Email, postData.VerifierCode); if (!isValidVerifierCode) { return(BadRequest("驗證碼驗證失敗.")); } string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); MemberDto memberDto = new MemberDto() { MemberID = memberID, Mobile = postData.Mobile, MoblieBindType = (int)MoblieBindType.Bind }; ResponseResultDto responseResult = await this.memberService.EditData(memberDto); if (responseResult.Ok) { return(Ok("綁定行動電話成功.")); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Reset Password Error >>> Email:{postData.Email} VerifierCode:{postData.VerifierCode}\n{ex}"); return(BadRequest("會員綁定行動電話發生錯誤.")); } }
public async Task <IActionResult> RejectJoin(RejectApplyForJoinPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamDto teamDto = new TeamDto() { TeamID = postData.TeamID, ExaminerID = memberID, TargetID = postData.TargetID }; ResponseResultDto responseResult = await this.teamService.RejectApplyForJoinTeam(teamDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Reject Apply For Join Team Error >>> TeamID:{postData.TeamID} ExaminerID:{memberID} TargetID:{postData.TargetID}\n{ex}"); return(BadRequest("拒絕申請加入車隊發生錯誤.")); } }
public async Task <IActionResult> Edit(EditTeamAnnouncementPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamAnnouncementDto teamAnnouncementDto = new TeamAnnouncementDto() { TeamID = postData.TeamID, MemberID = memberID, AnnouncementID = postData.AnnouncementID, Context = postData.Context }; ResponseResultDto responseResult = await this.teamService.EditTeamAnnouncementData(teamAnnouncementDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Edit Team Announcement Data Error >>> TeamID:{postData.TeamID} MemberID:{memberID} AnnouncementID:{postData.AnnouncementID} Context:{postData.Context}\n{ex}"); return(BadRequest("編輯車隊公告資料發生錯誤.")); } }
public async Task <IActionResult> GetVerifierCode(ForgetPasswordGetVerifierCodePostData postData) { try { string type = VerifierType.ForgetPassword.ToString(); string verifierCode = await this.verifierService.GetVerifierCode(type, postData.Email); if (string.IsNullOrEmpty(verifierCode)) { this.logger.LogError($"Get Verifier Code Fail For Get Verifier Code >>> Email:{postData.Email}"); return(BadRequest("取得查詢密碼驗證碼失敗.")); } EmailContext emailContext = EmailContext.GetVerifierCodetEmailContextForForgetPassword(postData.Email, verifierCode); ResponseResultDto responseResult = await this.verifierService.SendVerifierCode(type, postData.Email, verifierCode, emailContext); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Get Verifier Code Error >>> Email:{postData.Email}\n{ex}"); return(BadRequest("請求產生驗證碼發生錯誤.")); } }
public ResponseResultDto <MsgArticleDto> GetById(int id) { ResponseResultDto <MsgArticleDto> result = new ResponseResultDto <MsgArticleDto>(); try { var entity = this.articleRepository.GetById(id, true); if (null == entity) { result.ErrorMessage = "记录不存在或已删除"; } else { result.Result = new MsgArticleDto() { Id = entity.Id, Author = entity.Author, CategoryId = entity.CategoryId, CategoryName = entity.Category.Name, CreatedTime = entity.CreatedTime, MsgContent = entity.MsgContent, Title = entity.Title }; result.IsSuccess = true; } } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误"; } return(result); }
public ResponseResultDto <bool> AddArticle(MsgArticleDto article) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { MsgArticleEntity entity = new MsgArticleEntity() { Id = article.Id, Author = article.Author, CategoryId = article.CategoryId, CreatedTime = article.CreatedTime, MsgContent = article.MsgContent, Title = article.Title }; this.articleRepository.Insert(entity); result.IsSuccess = this.articleRepository.SaveChanged() > 0; result.Result = result.IsSuccess; } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误"; } return(result); }
public ResponseResultDto <bool> DeleteArticle(int id) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { var entity = this.articleRepository.Query(p => p.Id == id).FirstOrDefault(); if (null != entity) { this.articleRepository.Delete(entity); result.IsSuccess = this.articleRepository.SaveChanged() > 0; } else { result.IsSuccess = false; result.ErrorMessage = "记录不存在或已删除"; } result.Result = result.IsSuccess; } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误,请稍后重试"; } return(result); }
public ResponseResultDto <bool> DeleteArticle(List <int> idList) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { var entities = this.articleRepository.Query(p => idList.Contains(p.Id)).ToList(); if (entities?.Count > 0) { this.articleRepository.Delete(entities); result.IsSuccess = this.articleRepository.SaveChanged() > 0; } else { result.IsSuccess = false; result.ErrorMessage = "记录不存在或已删除"; } result.Result = result.IsSuccess; } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误,请稍后重试"; } return(result); }
public ResponseResultDto <bool> UpdateArticle(MsgArticleDto article) { ResponseResultDto <bool> result = new ResponseResultDto <bool>(); try { int count = this.articleRepository.Query(p => p.Id == article.Id).Count(); if (count <= 0) { result.ErrorMessage = "记录不存在或已删除"; } else { MsgArticleEntity entity = new MsgArticleEntity() { Id = article.Id, Author = article.Author, CategoryId = article.CategoryId, CreatedTime = article.CreatedTime, MsgContent = article.MsgContent, Title = article.Title }; this.articleRepository.Update(entity); result.IsSuccess = this.articleRepository.SaveChanged() > 0; result.Result = result.IsSuccess; } } catch (Exception ex) { result.IsSuccess = false; result.ErrorMessage = "服务错误"; } return(result); }
public async Task <IActionResult> Post(CreateTeamPostData postData) { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); try { TeamDto teamDto = new TeamDto() { TeamName = postData.TeamName, CityID = postData.CityID, TeamInfo = postData.TeamInfo, SearchStatus = postData.SearchStatus, ExamineStatus = postData.ExamineStatus, FrontCoverUrl = postData.FrontCoverUrl, PhotoUrl = postData.PhotoUrl, ExecutorID = memberID }; ResponseResultDto responseResult = await this.teamService.CreateTeam(teamDto); if (responseResult.Ok) { return(Ok(responseResult.Data)); } return(BadRequest(responseResult.Data)); } catch (Exception ex) { this.logger.LogError($"Create Team Error >>> MemberID:{memberID} PostData:{JsonConvert.SerializeObject(postData)}\n{ex}"); return(BadRequest("建立車隊發生錯誤.")); } }
/// <summary> /// 處理登入結果 /// </summary> /// <param name="responseResult">responseResult</param> /// <returns>IActionResult</returns> private async Task <IActionResult> HandleLoginResult(ResponseResultDto responseResult) { if (responseResult.Ok) { string[] dataArr = responseResult.Data; string memberID = dataArr[0]; string token = dataArr[1]; this.HttpContext.Session.SetObject(CommonFlagHelper.CommonFlag.SessionFlag.MemberID, memberID); ResponseResultDto recordSessionIDResult = await this.memberService.RecordSessionID(memberID, this.HttpContext.Session.Id); if (recordSessionIDResult.Ok) { //// TODO 傳送 Server 連線資訊 (先偷懶寫死 QQ) return(Ok(new MemberLoginInfoViewDto() { Token = token, ServerIP = "122.117.34.52", ServerPort = 1564 })); } else { return(BadRequest("會員登入失敗.")); } } return(BadRequest(responseResult.Data)); }
public async Task <IActionResult> Get() { string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID); ResponseResultDto recordSessionIDResult = await this.memberService.ExtendSessionIDExpire(memberID, this.HttpContext.Session.Id); if (!recordSessionIDResult.Ok) { return(BadRequest("Keep Online Fail.")); } return(Ok("Keep Online")); }
public async Task <IActionResult> Google(FBLoginPostData postData) { try { ResponseResultDto responseResult = await this.memberService.LoginGoogle(postData.Email, postData.Token); return(await this.HandleLoginResult(responseResult)); } catch (Exception ex) { this.logger.LogError($"Login Google Error >>> GoogleToken:{postData.Token}\n{ex}"); return(BadRequest("會員登入發生錯誤.")); } }
public async Task <IActionResult> Normal(NormalLoginPostData postData) { try { ResponseResultDto responseResult = await this.memberService.Login(postData.Email, postData.Password); return(await this.HandleLoginResult(responseResult)); } catch (Exception ex) { this.logger.LogError($"Normal Login Error >>> Email:{postData.Email} Password:{postData.Password}\n{ex}"); return(BadRequest("會員登入發生錯誤.")); } }