Exemplo n.º 1
0
        private async Task <long> SaveReturn(EditReturn model)
        {
            if (model.ReturnId == null)
            {
                var mCreateReturnItems = new List <MFulfillment_CreateReturnItem>();
                foreach (var item in model.ReturnItems)
                {
                    mCreateReturnItems.Add(new MFulfillment_CreateReturnItem()
                    {
                        ReturnRequestItemId = item.ReturnRequestItemId,
                        Quantity            = item.Quantity
                    });
                }

                var mCreateReturn = new MFulfillment_CreateReturn()
                {
                    CreateDateTimeUtc = Locale.GetUtcFromLocalTime(model.ReturnDate.Value),
                    CreateReturnItems = mCreateReturnItems
                };

                var aCreateReturn = new AReturn_CreateReturn()
                {
                    MCreateReturn = mCreateReturn
                };

                var returnId = await ReturnAdminService.CreateReturnAsync(aCreateReturn);

                return(returnId);
            }
            else
            {
                var mUpdateReturnItems = new List <MFulfillment_UpdateReturnItem>();
                foreach (var item in model.ReturnItems)
                {
                    mUpdateReturnItems.Add(new MFulfillment_UpdateReturnItem()
                    {
                        ReturnItemId = item.ReturnItemId.Value,
                        Quantity     = item.Quantity
                    });
                }

                var mUpdateReturn = new MFulfillment_UpdateReturn()
                {
                    CreateDateTimeUtc = Locale.GetUtcFromLocalTime(model.ReturnDate.Value),
                    UpdateReturnItems = mUpdateReturnItems
                };

                var aUpdateReturn = new AReturn_UpdateReturn()
                {
                    MUpdateReturn = mUpdateReturn
                };

                await ReturnAdminService.UpdateReturnAsync(aUpdateReturn);

                return(model.ReturnId.Value);
            }
        }
Exemplo n.º 2
0
        public async Task CreateReturn()
        {
            var logger = ServiceScope.ServiceProvider.GetService <ILogger <FulfillmentTest> >();

            var unitOfWork  = CreateUnitOfWork.Timestamp(GetUniqueNow());
            int maxQuantity = 10;

            var mReturnRequest = await SetupReturnRequest(unitOfWork, maxQuantity);

            var mCreateReturn = new MFulfillment_CreateReturn()
            {
                CreateDateTimeUtc = DateTime.Now,
                CreateReturnItems = mReturnRequest.ReturnRequestItems
                                    .Select(r => new MFulfillment_CreateReturnItem()
                {
                    ReturnRequestItemId = r.ReturnRequestItemId,
                    Quantity            = r.Quantity
                }).ToList()
            };
            var returnId = await FulfillmentMicroService.CreateReturnAsync(mCreateReturn);

            logger.LogInformation($"Return {returnId} created.");

            var eventCount = await EventProcessorMicroService.ProcessPendingEvents();

            logger.LogInformation($"{eventCount} events processed.");

            await FulfillmentMicroService.PostReturnAsync(returnId);

            logger.LogInformation($"Return {returnId} posted.");

            eventCount = await EventProcessorMicroService.ProcessPendingEvents();

            logger.LogInformation($"{eventCount} events processed.");

            await FulfillmentMicroService.ProcessReturnAsync(returnId);

            logger.LogInformation($"Return {returnId} processed.");

            eventCount = await EventProcessorMicroService.ProcessPendingEvents();

            logger.LogInformation($"{eventCount} events processed.");
        }