Esempio n. 1
0
        /// <summary>
        /// 取得活動詳細資訊
        /// </summary>
        /// <param name="teamCommand">teamCommand</param>
        /// <returns>Tuple(EventDetailInfoDto, string)</returns>
        public async Task <Tuple <EventDetailInfoDto, string> > GetEventDetailInfo(TeamCommandDto teamCommand)
        {
            try
            {
                bool verifyTeamCommandResult = this.VerifyTeamCommand(teamCommand, false, true, false, false, false, true);
                if (!verifyTeamCommandResult)
                {
                    this.logger.LogError($"Get Event Detail Info Fail For Verify TeamCommand >>> TeamID:{teamCommand.TeamID} TargetID:{teamCommand.TargetID} EventID:{(teamCommand.EventInfo != null ? teamCommand.EventInfo.EventID : "Null")}");
                    return(Tuple.Create <EventDetailInfoDto, string>(null, "取得活動詳細資訊失敗."));
                }

                if (string.IsNullOrEmpty(teamCommand.EventInfo.EventID))
                {
                    return(Tuple.Create <EventDetailInfoDto, string>(null, "活動編號無效."));
                }

                EventData eventData = await this.eventRepository.GetEventData(teamCommand.EventInfo.EventID);

                if (eventData == null)
                {
                    return(Tuple.Create <EventDetailInfoDto, string>(null, "活動不存在."));
                }

                TeamData teamData = await this.teamRepository.GetTeamData(teamCommand.TeamID);

                if (teamData == null)
                {
                    return(Tuple.Create <EventDetailInfoDto, string>(null, "車隊不存在."));
                }

                if (!teamData.TeamLeaderID.Equals(teamCommand.TargetID) && !teamData.TeamPlayerIDs.Contains(teamCommand.TargetID))
                {
                    return(Tuple.Create <EventDetailInfoDto, string>(null, "該會員非車隊隊員."));
                }

                bool updateHaveSeenMemberIDsResult = Utility.UpdateListHandler(eventData.HaveSeenMemberIDs, teamCommand.TargetID, true);
                if (updateHaveSeenMemberIDsResult)
                {
                    //// 無須對【已閱活動名單資料】作審查,不應影響原功能
                    bool result = await this.eventRepository.UpdateHaveSeenMemberIDs(teamData.TeamID, eventData.HaveSeenMemberIDs);
                }

                EventDetailInfoDto eventDetailInfo = this.mapper.Map <EventDetailInfoDto>(eventData);
                eventDetailInfo.TeamName  = teamData.TeamName;
                eventDetailInfo.TeamPhoto = teamData.TeamPhoto;
                return(Tuple.Create(eventDetailInfo, string.Empty));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Get Event Detail Info Error >>> TeamID:{teamCommand.TeamID} TargetID:{teamCommand.TargetID} EventID:{(teamCommand.EventInfo != null ? teamCommand.EventInfo.EventID : "Null")}\n{ex}");
                return(Tuple.Create <EventDetailInfoDto, string>(null, "取得活動詳細資訊發生錯誤."));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 活動資料更新處理
        /// </summary>
        /// <param name="eventInfo">eventInfo</param>
        /// <param name="eventData">eventData</param>
        /// <returns>string</returns>
        private string UpdateEventDataHandler(EventDetailInfoDto eventInfo, EventData eventData)
        {
            if (eventInfo.EventDate == null)
            {
                return("無活動日期.");
            }

            if (string.IsNullOrEmpty(eventInfo.EventTitle))
            {
                return("無活動標題.");
            }

            if (string.IsNullOrEmpty(eventInfo.Site))
            {
                return("無集合地點.");
            }

            if (string.IsNullOrEmpty(eventInfo.Description))
            {
                return("無路線描述.");
            }

            DateTime createDate = eventData.CreateDate;

            if (eventInfo.EventDate.CompareTo(createDate) < 0)
            {
                return("活動日期需大於現在時間.");
            }

            int countDays = new TimeSpan((eventInfo.EventDate - createDate).Ticks).Days;

            if (countDays > AppSettingHelper.Appsetting.EventMaxDate)
            {
                return("活動預約請設定於90天內.");
            }

            eventData.EventDate         = eventInfo.EventDate;
            eventData.Site              = eventInfo.Site;
            eventData.Description       = eventInfo.Description;
            eventData.HaveSeenMemberIDs = new List <string>();
            eventData.SaveDeadline      = new DateTime(eventInfo.EventDate.Year, eventInfo.EventDate.Month, eventInfo.EventDate.Day, 23, 59, 59);
            return(string.Empty);
        }
Esempio n. 3
0
        /// <summary>
        /// 創建新活動資料
        /// </summary>
        /// <param name="teamID">teamID</param>
        /// <param name="teamName">teamName</param>
        /// <param name="creatorID">publisherID</param>
        /// <param name="eventInfo">eventInfo</param>
        /// <returns>Tuple(EventData, string)</returns>
        private async Task <Tuple <EventData, string> > CreateEventData(string teamID, string teamName, string creatorID, EventDetailInfoDto eventInfo)
        {
            if (eventInfo.EventDate == null)
            {
                return(Tuple.Create <EventData, string>(null, "無活動日期."));
            }

            if (string.IsNullOrEmpty(eventInfo.EventTitle))
            {
                return(Tuple.Create <EventData, string>(null, "無活動標題."));
            }

            if (string.IsNullOrEmpty(eventInfo.Site))
            {
                return(Tuple.Create <EventData, string>(null, "無集合地點."));
            }

            if (string.IsNullOrEmpty(eventInfo.Description))
            {
                return(Tuple.Create <EventData, string>(null, "無路線描述."));
            }

            bool verifyEventDataByCreatorIDResult = await this.eventRepository.VerifyEventDataByCreatorID(creatorID);

            if (verifyEventDataByCreatorIDResult)
            {
                return(Tuple.Create <EventData, string>(null, "無法建立兩個以上的活動."));
            }

            DateTime createDate = DateTime.Now;

            if (eventInfo.EventDate.CompareTo(createDate) < 0)
            {
                return(Tuple.Create <EventData, string>(null, "活動日期需大於現在時間."));
            }

            int countDays = new TimeSpan((eventInfo.EventDate - createDate).Ticks).Days;

            if (countDays > AppSettingHelper.Appsetting.EventMaxDate)
            {
                return(Tuple.Create <EventData, string>(null, "活動預約請設定於90天內."));
            }

            EventData eventData = this.mapper.Map <EventData>(eventInfo);

            eventData.EventID        = this.GetSerialID(createDate);
            eventData.TeamID         = teamID;
            eventData.CreatorID      = creatorID;
            eventData.CreateDate     = createDate;
            eventData.RoutePoints    = new List <string>();
            eventData.JoinMemberList = new List <string>()
            {
                creatorID
            };
            eventData.HaveSeenMemberIDs = new List <string>();
            eventData.SaveDeadline      = new DateTime(eventInfo.EventDate.Year, eventInfo.EventDate.Month, eventInfo.EventDate.Day, 23, 59, 59);
            return(Tuple.Create(eventData, string.Empty));
        }