Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(DeleteTeamAnnouncementPostData 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
                };
                ResponseResultDto responseResult = await this.teamService.DeleteTeamAnnouncementData(teamAnnouncementDto);

                if (responseResult.Ok)
                {
                    return(Ok(responseResult.Data));
                }

                return(BadRequest(responseResult.Data));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Delete Team Announcement Data Error >>> TeamID:{postData.TeamID} MemberID:{memberID} AnnouncementID:{postData.AnnouncementID}\n{ex}");
                return(BadRequest("刪除車隊公告資料發生錯誤."));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(CreateTeamAnnouncementPostData postData)
        {
            string memberID = this.HttpContext.Session.GetObject <string>(CommonFlagHelper.CommonFlag.SessionFlag.MemberID);

            try
            {
                TeamAnnouncementDto teamAnnouncementDto = new TeamAnnouncementDto()
                {
                    TeamID    = postData.TeamID,
                    MemberID  = memberID,
                    Context   = postData.Context,
                    LimitDate = postData.LimitDate
                };
                ResponseResultDto responseResult = await this.teamService.CreateTeamAnnouncementData(teamAnnouncementDto);

                if (responseResult.Ok)
                {
                    return(Ok(responseResult.Data));
                }

                return(BadRequest(responseResult.Data));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Create Team Announcement Data Error >>>  MemberID:{memberID} Data:{JsonConvert.SerializeObject(postData)}\n{ex}");
                return(BadRequest("建立車隊公告資料發生錯誤."));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(TeamAnnouncementDto teamAnnouncementDto)
        {
            try
            {
                string result = await this.teamService.EditTeamAnnouncementData(teamAnnouncementDto);

                if (string.IsNullOrEmpty(result))
                {
                    return(Ok("編輯車隊公告資料成功."));
                }

                return(BadRequest(result));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Edit Team Announcement Data Error >>> Data:{JsonConvert.SerializeObject(teamAnnouncementDto)}\n{ex}");
                return(BadRequest("編輯車隊公告資料發生錯誤."));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(TeamAnnouncementDto teamAnnouncementDto)
        {
            try
            {
                string result = await this.teamService.DeleteTeamAnnouncementData(teamAnnouncementDto);

                if (string.IsNullOrEmpty(result))
                {
                    return(Ok("刪除車隊公告資料成功."));
                }

                return(BadRequest(result));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Delete Team Announcement Data Error >>> TeamID:{teamAnnouncementDto.TeamID} AnnouncementID:{teamAnnouncementDto.AnnouncementID} MemberID:{teamAnnouncementDto.MemberID}\n{ex}");
                return(BadRequest("刪除車隊公告資料發生錯誤."));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 編輯車隊公告資料
 /// </summary>
 /// <param name="teamAnnouncementDto">teamAnnouncementDto</param>
 /// <returns>ResponseResultDto</returns>
 public async Task<ResponseResultDto> EditTeamAnnouncementData(TeamAnnouncementDto teamAnnouncementDto)
 {
     try
     {
         string postData = JsonConvert.SerializeObject(teamAnnouncementDto);
         HttpResponseMessage httpResponseMessage = await Utility.ApiPost(AppSettingHelper.Appsetting.ServiceDomain.Service, "api/Team/Announcement/Edit", postData);
         return new ResponseResultDto()
         {
             Ok = httpResponseMessage.IsSuccessStatusCode,
             Data = await httpResponseMessage.Content.ReadAsAsync<string>()
         };
     }
     catch (Exception ex)
     {
         this.logger.LogError($"Edit Team Announcement Data Error >>> Data:{JsonConvert.SerializeObject(teamAnnouncementDto)}\n{ex}");
         return new ResponseResultDto()
         {
             Ok = false,
             Data = "編輯車隊公告資料發生錯誤."
         };
     }
 }