/// <summary> /// convert accountCode to view model /// </summary> /// <param name="code"></param> /// <returns></returns> public AccountCodeViewModel ConvertToView(AccountCode code) { AccountCodeViewModel model = new AccountCodeViewModel(); var _customerDynamicsRepository = new CustomerDynamicsRepository(); var _bucketRepository = new BucketRepository(); var dynamicsCustomer = _customerDynamicsRepository.GetCustomer(code.CustomerId); var bucket = _bucketRepository.GetBucket(code.AccountCodeId); model.AccountCodeId = code.AccountCodeId; model.Description = (!string.IsNullOrEmpty(code.Description)) ? code.Description : "N/A"; model.CustomerId = code.CustomerId; model.CustomerName = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A"; model.BucketName = (bucket != null && !string.IsNullOrEmpty(bucket.Name)) ? bucket.Name : "N/A"; if (_customerDynamicsRepository != null) { _customerDynamicsRepository.Dispose(); _customerDynamicsRepository = null; } if (_bucketRepository != null) { _bucketRepository.Dispose(); _bucketRepository = null; } return(model); }
public BucketController(BucketRepository bucketRepository , OrderService orderService , WarehouseServiceClient warehouseServiceClient , IMapper mapper) { _bucketRepository = bucketRepository; _mapper = mapper; _orderService = orderService; _warehouseServiceClient = warehouseServiceClient; }
/// <summary> /// convert foundry invoice to view model /// </summary> /// <param name="invoice"></param> /// <returns></returns> public FoundryInvoiceViewModel ConvertToView(FoundryInvoice invoice) { FoundryInvoiceViewModel model = new FoundryInvoiceViewModel(); var _foundryDynamicsRepository = new FoundryDynamicsRepository(); var _bucketRepository = new BucketRepository(); var dynamicsFoundry = _foundryDynamicsRepository.GetFoundry(invoice.FoundryId); var buckets = _bucketRepository.GetBuckets().Where(x => x.FoundryInvoiceId == invoice.FoundryInvoiceId).ToList(); model.FoundryInvoiceId = invoice.FoundryInvoiceId; model.BillOfLadingId = invoice.FoundryInvoiceId; model.InvoiceNumber = (!string.IsNullOrEmpty(invoice.Number)) ? invoice.Number : "N/A"; model.InvoiceAmount = invoice.Amount; model.ScheduledPaymentDate = (invoice.ScheduledPaymentDate != null) ? invoice.ScheduledPaymentDate : DateTime.MinValue; model.ScheduledPaymentDateStr = (invoice.ScheduledPaymentDate != null) ? invoice.ScheduledPaymentDate.Value.ToShortDateString() : "N/A"; model.ActualPaymentDate = (invoice.ActualPaymentDate != null) ? invoice.ActualPaymentDate : DateTime.MinValue;; model.ActualPaymentDateStr = (invoice.ActualPaymentDate != null) ? invoice.ActualPaymentDate.Value.ToShortDateString() : "N/A"; model.Notes = (!string.IsNullOrEmpty(invoice.Notes)) ? invoice.Notes : "N/A"; model.FoundryId = invoice.FoundryId; model.FoundryName = (dynamicsFoundry != null && !string.IsNullOrEmpty(dynamicsFoundry.VENDSHNM)) ? dynamicsFoundry.VENDSHNM : "N/A"; model.AirFreight = invoice.AirFreight; model.HasBeenProcessed = invoice.HasBeenProcessed; model.CreateDate = (invoice.CreatedDate != null) ? invoice.CreatedDate : DateTime.MinValue; model.CreateDateStr = (invoice.CreatedDate != null) ? invoice.CreatedDate.Value.ToShortDateString() : "N/A"; model.Buckets = new List <BucketViewModel>(); if (buckets != null && buckets.Count > 0) { foreach (var bucket in buckets) { BucketViewModel convertedModel = new BucketConverter().ConvertToView(bucket); model.Buckets.Add(convertedModel); } } if (_foundryDynamicsRepository != null) { _foundryDynamicsRepository.Dispose(); _foundryDynamicsRepository = null; } if (_bucketRepository != null) { _bucketRepository.Dispose(); _bucketRepository = null; } return(model); }
public OrderService(OrderContext orderContext , UserContext userContext , BucketRepository bucketRepository , PriceServiceClient pricingClient , WarehouseServiceClient warehouseServiceClient , RabbitMQMessageSender mqSender , MetricReporter metricReporter , IDistributedCache distributedCache) { _orderContext = orderContext; _userContext = userContext; _pricingClient = pricingClient; _warehouseServiceClient = warehouseServiceClient; _bucketRepository = bucketRepository; _mqSender = mqSender; _metricReporter = metricReporter; _distributedCache = distributedCache; }
public BucketController(BucketRepository bucketRepository) { _bucketRepository = bucketRepository; }
public SaveResponse( long requestID, Response <Reply> response, BucketRepository bucketRepo, TimeoutSourceRepository timeoutSourceRepo, AConnection db, ASafeLog log ) : base(db, log) { Tbl = null; if (response == null) { return; } this.timeoutSourceRepo = timeoutSourceRepo; this.dbr = new DbResponse { ServiceLogID = requestID, HttpStatus = (int)response.Status, ReceivedTime = DateTime.UtcNow, }; if (response.ParsingException == null) { this.dbr.ParsingExceptionType = null; this.dbr.ParsingExceptionMessage = null; } else { this.dbr.ParsingExceptionType = response.ParsingException.GetType().FullName; this.dbr.ParsingExceptionMessage = response.ParsingException.Message; } // if if (response.Parsed.Exists()) { Bucket bucket = null; if ((bucketRepo != null) && response.Parsed.HasDecision()) { bucket = bucketRepo.Find(response.Parsed.Inference.Decision.Bucket); } this.timeoutSource = response.Parsed.Timeout; this.dbr.ResponseStatus = (int)response.Parsed.Status; this.dbr.ErrorMessage = response.Parsed.Error; this.dbr.BucketID = bucket == null ? (int?)null : bucket.Value; this.dbr.HasEquifaxData = response.Parsed.HasEquifaxData(); this.dbr.Reason = response.Parsed.Reason; this.dbr.Outcome = response.Parsed.Outcome; } else { this.timeoutSource = null; this.dbr.ResponseStatus = 0; this.dbr.TimeoutSourceID = null; this.dbr.ErrorMessage = null; this.dbr.BucketID = null; this.dbr.HasEquifaxData = false; this.dbr.Reason = null; this.dbr.Outcome = null; } // if Tbl = new List <DbResponse> { this.dbr, }; } // constructor