Exemplo n.º 1
0
        /// <summary>
        /// Accept invitation
        /// </summary>
        /// <param name="activeCode"></param>
        /// <returns></returns>
        public async Task <ResultModel <AccountInfoModel> > AcceptInvitation(string activeCode)
        {
            ResultModel <AccountInfoModel> iResult = new ResultModel <AccountInfoModel>();

            ProjectMember inviteItem = await UnitOfWork
                                       .ProjectMemberRepository
                                       .GetAsync(c => c.IsPending && c.ActiveCode == activeCode);

            if (inviteItem == null)
            {
                iResult.Status = ActionStatus.NotFound;
            }
            else
            {
                inviteItem.IsPending = false;

                UnitOfWork.ProjectMemberRepository.Update(inviteItem);

                var result = await UnitOfWork.CommitAsync();

                if (result > 0)
                {
                    iResult.Data = await _accountBusiness.GetAccountInfo(inviteItem.MemberId);

                    iResult.Status = ActionStatus.Ok;
                }
            }
            return(iResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compare changes of old and new task
        /// </summary>
        /// <param name="newData"></param>
        /// <param name="oldData"></param>
        /// <returns></returns>
        public async Task <string> CompareChangesAsync(TaskItemModel newData, TaskItemModel oldData)
        {
            if (newData.TaskId != oldData.TaskId)
            {
                return(string.Empty);
            }

            string content = string.Empty;

            if (newData.TaskTitle != oldData.TaskTitle)
            {
                content += FormartHistoryContent("Title", oldData.TaskTitle, newData.TaskTitle);
            }

            if (newData.TaskDetail != oldData.TaskDetail)
            {
                content += FormartHistoryContent("Detail", oldData.TaskDetail, newData.TaskDetail);
            }

            if (newData.Phase.Id != oldData.Phase.Id)
            {
                string oldItem = "Open Features";
                string newItem = "Open Features";
                if (newData.Phase.Id > 0)
                {
                    PhaseModel phase = await _phase.GetPhaseById(newData.Phase.Id);

                    newItem = phase.PhaseName;
                }
                if (oldData.Phase.Id > 0)
                {
                    PhaseModel phase = await _phase.GetPhaseById(oldData.Phase.Id);

                    oldItem = phase.PhaseName;
                }
                content += FormartHistoryContent("Phase", oldItem, newItem);
            }

            if (newData.Assignee.AccountId != oldData.Assignee.AccountId)
            {
                string oldItem = "Non-Assigned";
                string newItem = "Non-Assigned";
                if (newData.Assignee.AccountId > 0)
                {
                    AccountInfoModel account = await _account.GetAccountInfo(newData.Assignee.AccountId);

                    newItem = account.DisplayName;
                }
                if (oldData.Assignee.AccountId > 0)
                {
                    AccountInfoModel account = await _account.GetAccountInfo(oldData.Assignee.AccountId);

                    oldItem = account.DisplayName;
                }
                content += FormartHistoryContent("Assignee", oldItem, newItem);
            }

            if (newData.Priority != oldData.Priority)
            {
                string oldItem = oldData.Priority.ToString();
                string newItem = newData.Priority.ToString();
                content += FormartHistoryContent("Priority", oldItem, newItem);
            }

            if (newData.Status != oldData.Status)
            {
                string oldItem = oldData.Status.ToString();
                string newItem = newData.Status.ToString();
                content += FormartHistoryContent("Status", oldItem, newItem);
            }

            if (newData.PercentCompleted != oldData.PercentCompleted)
            {
                string oldItem = oldData.PercentCompleted.ToString();
                string newItem = newData.PercentCompleted.ToString();
                content += FormartHistoryContent("Percent Completed", oldItem, newItem);
            }

            return(content);
        }