コード例 #1
0
        public PromotionResult PromoteWorkListItem(string command)
        {
            var promotionResult = new PromotionResult();

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

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

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

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

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

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

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

            Log4NetHelper.Log(promotionResult.Message, LogLevel.INFO, "WorkOrders", WorkOrderId, HttpContext.Current.User.Identity.Name, null);

            if (promotionResult.Success)
            {
                CurrentWorker   = null;
                CurrentWorkerId = null;

                // Attempt auto-promotion from Certified to Approved if the total value of Parts & Labors
                // is less than $5000.
                if (WorkOrderStatus == WorkOrderStatus.Certified && Parts.Sum(p => p.ExtendedPrice) + Labors.Sum(l => l.ExtendedPrice) < 5000)
                {
                    PromotionResult autoPromotionResult = PromoteToApproved();

                    if (autoPromotionResult.Success)
                    {
                        promotionResult         = autoPromotionResult;
                        promotionResult.Message = "AUTOMATIC PROMOTION: " + promotionResult.Message;
                    }
                }
            }

            return(promotionResult);
        }
コード例 #2
0
        public PromotionResult PromoteWorkOrder(string command)
        {
            PromotionResult promotion = new PromotionResult();

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

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

            case "PromoteToCertified":
                promotion = PromoteToCertified();
                break;

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

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

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

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

            if (promotion.Success)
            {
                CurrentWorker   = null;
                CurrentWorkerId = null;

                // Attempt to auto-promote from certified to Approved
                if (WorkOrderStatus == WorkOrderStatus.Certified && Parts.Sum(p => p.ExtendedPrice) + Labors.Sum(l => l.ExtendedPrice) < 5000)
                {
                    PromotionResult autoPromote = PromoteToApproved();

                    if (autoPromote.Success)
                    {
                        promotion         = autoPromote;
                        promotion.Message = $"AUTOMATIC PROMOTION: {promotion.Message}";
                    }
                }
            }

            return(promotion);
        }