public async Task <ApiResult <string> > UpsertPOContempo(MMS.PO.Events.MMSPOEvent model)
        {
            try
            {
                string ponumber = model.PONumber;
                _logger.LogInformation("Passed in {PONumber}.", model.PONumber);

                _logger.LogDebug("Fetching existing data for {PONumber}", ponumber);
                var existing = await GetExistingPO(ponumber);

                if (existing.poContempo != null)
                {
                    existing.poContempo = model.MapEventtoOutput(existing.poContempo);

                    if (existing.poContempo.POSkus != null && existing.poContempo.POSkus.Count > 0)
                    {
                        //update data in elastic
                        _logger.LogInformation("Going to update data for {PONumber} in elastic", ponumber);
                        var response = await _getDataService.UpdateItem <POContempoOutput>(existing.poContempo, _poIndex);

                        _logger.LogDebug("Updated data for {PONumber} in elastic", ponumber);
                    }
                    else
                    {
                        _logger.LogDebug("No SKUs found for {PONumber}. PO Data not updated in elastic.", ponumber);
                    }
                }
                return(new ApiResult <string>());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpsertPOContempo - Failed Updating ContempoPO: {Reason}", ex.Message);
                return(new ApiResult <string>(new[] { ex.Message }));
            }
        }
示例#2
0
        public async Task <ApiResult <string> > UpsertPOAPL(MMS.PO.Events.MMSPOEvent model)
        {
            try
            {
                string ponumber = model.PONumber;
                _logger.LogInformation("Passed in {PONumber}.", model.PONumber);

                _logger.LogInformation("Fetching existing data for {PONumber}", ponumber);
                var existing = await GetExistingPO(ponumber);

                if (existing.POAPL != null)
                {
                    //if (existing.POAPL.CheckPoStatus())//filter conditions
                    //{
                    existing.POAPL = model.MapEventtoOutput(existing.POAPL);

                    _logger.LogInformation("Going to update data for {PONumber} in elastic", ponumber);
                    var response = await _getDataService.UpdateItem <POAPLLOutput>(existing.POAPL, _poIndex);

                    _logger.LogDebug("Updated data for {PONumber} in elastic", ponumber);
                    //}
                }
                // existing.POAPL.ActivityCode = model.GetType() == typeof(MMSPOCreatedEvent) ? "A" : "U";

                return(new ApiResult <string>());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpsertPOAPL- Failed Updating APLPO: {Reason}", ex.Message);
                return(new ApiResult <string>(new[] { ex.Message }));
            }
        }
示例#3
0
        public async Task <ApiResult <string> > UpsertPOIntertek(MMS.PO.Events.MMSPOEvent model)
        {
            try
            {
                string ponumber = model.PONumber;
                _logger.LogInformation("Passed in {PONumber}.", model.PONumber);

                _logger.LogDebug("Fetching existing data for {PONumber}", ponumber);
                var existing = await GetExistingPO(ponumber);

                if (existing.POIntertek != null)
                {
                    existing.POIntertek = model.MapEventtoOutput(existing.POIntertek);

                    //update data in elastic
                    _logger.LogInformation("Going to update data for {PONumber} in elastic", ponumber);

                    var response = await _getDataService.UpdateItem <POIntertekOutput>(existing.POIntertek, _poIndex);

                    _logger.LogDebug("Updated data for {PONumber} in elastic", ponumber);
                }

                return(new ApiResult <string>());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpsertPOIntertek - Failed Updating IntertekPO: {Reason}", ex.Message);
                return(new ApiResult <string>(new[] { ex.Message }));
            }
        }
示例#4
0
        public async Task <ApiResult <string> > UpsertPOChino(MMS.PO.Events.MMSPOEvent model)
        {
            try
            {
                string ponumber = model.PONumber;
                _logger.LogInformation("Passed in {PONumber}.", model.PONumber);

                _logger.LogDebug("Fetching existing data for {PONumber}", ponumber);
                var existing = await GetExistingPO(ponumber);

                if (existing.POChino != null)
                {
                    existing.POChino = model.MapEventtoOutput(existing.POChino);
                    if (existing.POChino.POSkus != null && existing.POChino.POSkus.Count > 0)
                    {
                        existing.POChino.POSkus = existing.POChino.POSkus.FindAll(x => Convert.ToInt32(x.OrderQty) > 0);
                    }
                    _logger.LogInformation("Going to update data for {PONumber} in elastic", ponumber);
                    var response = await _getDataService.UpdateItem <POChinoOutput>(existing.POChino, _index);

                    _logger.LogDebug("Updated data for {PONumber} in elastic", ponumber);
                }

                return(new ApiResult <string>());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "UpsertPOChino- Failed Updating ChinoPO: {Reason}", ex.Message);
                return(new ApiResult <string>(new[] { ex.Message }));
            }
        }