コード例 #1
0
        public async Task <Guid> ProccessIps(BatchIpsModel batchIps)
        {
            Batch batch = new Batch()
            {
                Id = Guid.NewGuid(),
                InsertionDateTime = DateTime.Now,
                StatusId          = 1
            };

            _repositoryDB.Add(batch);

            foreach (var ip in batchIps.Ip)
            {
                batch.BatchDetails.Add(new BatchDetail {
                    Ip = ip
                });
            }


            await _repositoryDB.SaveChangesAsync();



            return(batch.Id);
        }
コード例 #2
0
        public async Task <IActionResult> PostBatch(BatchIpsModel iPs)
        {
            try
            {
                BatchProcessor br      = new BatchProcessor(_mapper, _repository, _repositoryDB);
                Guid           batchid = await br.ProccessIps(iPs);

                var batchAdded = await _batchProcessingChannel.AddBatchAsync(batchid);

                if (batchAdded)
                {
                    var link = _linkGenerator.GetPathByAction(
                        HttpContext,
                        "Get",
                        values: new { id = batchid });

                    var fullLink = $" { HttpContext.Request.Scheme }://{ HttpContext.Request.Host}{link}";

                    return(Created(link, fullLink));
                }

                return(this.StatusCode(StatusCodes.Status500InternalServerError));
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError));
            }
        }