public PromotionResult PromoteWorkListItem(string command)
        {
            PromotionResult promotionResult = new PromotionResult();

            switch (command)
            {
            case "PromoteToCreated":
                promotionResult = PromoteToCreated();
                break;

            case "PromoteToProcessed":
                promotionResult = PromoteToProcessed();
                break;

            case "PromoteToApproved":
                promotionResult = PromoteToApproved();
                break;

            case "DemoteToCreated":
                promotionResult = DemoteToCreated();
                break;

            case "DemoteToRejected":
                promotionResult = DemoteToRejected();
                break;

            case "DemoteToCanceled":
                promotionResult = DemoteToCanceled();
                break;
            }

            return(promotionResult);
        }
        public PromotionResult ClaimWorkListItem(string userId)
        {
            PromotionResult promotionResult = new PromotionResult {
                Success = true
            };

            if (!promotionResult.Success)
            {
                return(promotionResult);
            }

            switch (applicationFormStatus)
            {
            case ApplicationFormStatus.Rejected:
                promotionResult = PromoteToProcessing();
                break;

            case ApplicationFormStatus.Created:
                promotionResult = PromoteToProcessing();
                break;

            case ApplicationFormStatus.Processed:
                promotionResult = PromoteToApproving();
                break;
            }


            return(promotionResult);
        }
        private PromotionResult DemoteToCreated()
        {
            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = true;

            if (applicationFormStatus != ApplicationFormStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Created status because its current status prevented it.";
            }

            //if (String.IsNullOrWhiteSpace(ReworkNotes))
            //{
            //    promotionResult.Success = false;
            //    promotionResult.Message = "Failed to demote the work order to Created status because Rework Notes must be present.";
            //}

            if (promotionResult.Success)
            {
                applicationFormStatus   = ApplicationFormStatus.Created;
                promotionResult.Message = String.Format("Work order {0} successfully demoted to status {1}.", Id, applicationFormStatus);
            }

            return(promotionResult);
        }
        private PromotionResult PromoteToApproving()
        {
            if (applicationFormStatus == ApplicationFormStatus.Processed)
            {
                applicationFormStatus = ApplicationFormStatus.Approving;
            }

            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = applicationFormStatus == ApplicationFormStatus.Approving;

            if (promotionResult.Success)
            {
                promotionResult.Message = String.Format("Work order {0} successfully claimed by {1} and promoted to status {2}.",
                                                        Id,
                                                        HttpContext.Current.User.Identity.Name,
                                                        applicationFormStatus);
            }
            else
            {
                promotionResult.Message = "Failed to promote the work order to Approving status because its current status prevented it.";
            }

            return(promotionResult);
        }
        private PromotionResult DemoteToCanceled()
        {
            PromotionResult promotionResult = new PromotionResult();

            promotionResult.Success = true;

            if (applicationFormStatus != ApplicationFormStatus.Approving)
            {
                promotionResult.Success = false;
                promotionResult.Message = "Failed to demote the work order to Canceled status because its current status prevented it.";
            }

            if (promotionResult.Success)
            {
                applicationFormStatus   = ApplicationFormStatus.Canceled;
                promotionResult.Message = String.Format("Work order {0} successfully demoted to status {1}.", Id, applicationFormStatus);
            }

            return(promotionResult);
        }