public static IStatusGeneric <ActivityStatusHistory> CreateActivityStatusHistory(ActivityHolBy holdBy,
                                                                                         string description, DateTime createDate)
        {
            var pstatus     = new StatusGenericHandler <ActivityStatusHistory>();
            var activityHis = new ActivityStatusHistory
            {
                CreateDate  = createDate,
                Description = description,
                HoldBy      = holdBy
            };

            pstatus.Result = activityHis;
            return(pstatus);
        }
示例#2
0
        public IStatusGeneric UpdateActivityStatus(ActivityStatus status,
                                                   ActivityHolBy acHoldBy, ActivityCondition condition)
        {
            var pstatus = new StatusGenericHandler();

            if (this.Status == Common.ActivityStatus.Done)
            {
                pstatus.AddError("activity status unable to edit!!!");
            }

            if (condition == Common.ActivityCondition.Hold)
            {
                if (acHoldBy == Common.ActivityHolBy.NoHold)
                {
                    pstatus.AddError("Please select a hold attribute!!!");
                }
            }

            if (!pstatus.HasErrors)
            {
                if (status == ActivityStatus.Ongoing)
                {
                    this.ActualStartDate = DateTime.Now;
                }
                else if (status == ActivityStatus.Done)
                {
                    this.Progress      = 100;
                    this.ActualEndDate = DateTime.Now;
                }
                else if (status == ActivityStatus.Reject || status == ActivityStatus.Delete)
                {
                    this.Progress     = 0;
                    this.WeightFactor = 0;
                }

                this.Condition = condition;
                this.Status    = status;

                string description = $"{status} - {condition}";

                this.StatusHistory.Add(ActivityStatusHistory.CreateActivityStatusHistory(acHoldBy, description, DateTime.Now).Result);
            }

            return(pstatus);
        }