コード例 #1
0
ファイル: LabController.cs プロジェクト: benningd54/Anlab
        /// <summary>
        /// This should probably be moved to a service...
        /// </summary>
        /// <param name="order"></param>
        /// <param name="result"></param>
        /// <param name="finalizeModel"></param>
        /// <returns></returns>
        private async Task <Order> UpdateOrderFromLabworksResult(Order order, OverwriteOrderResult result, LabFinalizeModel finalizeModel = null)
        {
            order.ClientId   = result.ClientId;
            order.ClientName = "[Not Found]"; //Updated below if we find it
            var orderDetails = order.GetOrderDetails();

            if (!string.IsNullOrWhiteSpace(order.ClientId))
            {
                //TODO: update other info if we pull it: phone numbers
                var clientInfo = await _labworksService.GetClientDetails(order.ClientId);

                if (clientInfo != null)
                {
                    orderDetails.ClientInfo.ClientId    = order.ClientId;
                    orderDetails.ClientInfo.Email       = clientInfo.SubEmail;
                    orderDetails.ClientInfo.Name        = clientInfo.Name;
                    orderDetails.ClientInfo.PhoneNumber = clientInfo.SubPhone;
                    orderDetails.ClientInfo.CopyPhone   = clientInfo.CopyPhone;
                    orderDetails.ClientInfo.Department  = clientInfo.Department;
                    order.ClientName = clientInfo.Name;
                }

                order.AdditionalEmails = AdditionalEmailsHelper.AddClientInfoEmails(order, orderDetails.ClientInfo);
            }

            if (result.MissingTestsToAdd.Any())
            {
                var allTests = order.GetTestDetails();
                foreach (var missingTest in result.MissingTestsToAdd)
                {
                    allTests.Add(missingTest);
                }
                order.SaveTestDetails(allTests);
            }

            orderDetails.Quantity                  = result.Quantity;
            orderDetails.SelectedTests             = result.SelectedTests;
            orderDetails.Total                     = orderDetails.SelectedTests.Sum(x => x.Total) + (orderDetails.Payment.IsInternalClient ? orderDetails.InternalProcessingFee : orderDetails.ExternalProcessingFee);
            orderDetails.Total                     = orderDetails.Total * result.RushMultiplier;
            orderDetails.RushMultiplier            = result.RushMultiplier;
            orderDetails.LabworksSampleDisposition = result.LabworksSampleDisposition;

            if (finalizeModel != null)
            {
                orderDetails.LabComments      = finalizeModel.LabComments;
                orderDetails.AdjustmentAmount = finalizeModel.AdjustmentAmount;
                if (orderDetails.AdjustmentAmount != 0)
                {
                    orderDetails.AdjustmentComments = finalizeModel.AdjustmentComments;
                }
            }



            order.SaveDetails(orderDetails);
            order.SaveBackedupTestDetails(result.BackedupTests);

            return(order);
        }
コード例 #2
0
        public void PopulateOrder(OrderSaveModel model, Order orderToUpdate)
        {
            orderToUpdate.Project    = model.Project;
            orderToUpdate.ClientId   = model.ClientInfo.ClientId;
            orderToUpdate.ClientName = model.ClientInfo.Name;

            orderToUpdate.JsonDetails = JsonConvert.SerializeObject(model);
            var orderDetails = orderToUpdate.GetOrderDetails();

            orderDetails.Payment.Account = orderDetails.Payment.Account.SafeToUpper(); //Make sure any account is all upper case

            var tests = CalculateTestDetails(orderToUpdate);

            orderDetails.SelectedTests = tests.ToArray();
            orderDetails.Total         = orderDetails.SelectedTests.Sum(x => x.Total) + (orderDetails.Payment.IsInternalClient ? orderDetails.InternalProcessingFee : orderDetails.ExternalProcessingFee);

            orderToUpdate.SaveDetails(orderDetails);

            orderToUpdate.AdditionalEmails = string.Join(";", orderDetails.AdditionalEmails);

            orderToUpdate.AdditionalEmails = AdditionalEmailsHelper.AddClientInfoEmails(orderToUpdate, orderDetails.ClientInfo);

            if (orderDetails.Payment.IsInternalClient)
            {
                var account = new AccountModel(orderDetails.Payment.Account);
                if (account.Chart == "3" || account.Chart == "L" || account.Chart == "H" || account.Chart == "M") //Removed S as a choice and added H to match _checkUcChart in react code
                {
                    orderToUpdate.PaymentType = PaymentTypeCodes.UcDavisAccount;
                }
                else
                {
                    orderToUpdate.PaymentType = PaymentTypeCodes.UcOtherAccount;
                }
            }
            else
            {
                if (orderDetails.OtherPaymentInfo == null || string.IsNullOrWhiteSpace(orderDetails.OtherPaymentInfo.PaymentType))
                {
                    orderToUpdate.PaymentType = PaymentTypeCodes.CreditCard;
                }
                else
                {
                    orderToUpdate.PaymentType = PaymentTypeCodes.Other;
                }
            }
        }