public async Task <IActionResult> AddCutPoint([FromBody] CreateCutPointRequest request)
        {
            var result = await _cutPointService.CreateCutPointAsync(request);

            var mapped = _mapper.Map <CutPointResponse>(result);

            return(Created("", new ApiOkResponse(mapped)));
        }
Exemplo n.º 2
0
        public async Task <CutPoint> CreateCutPointAsync(CreateCutPointRequest request)
        {
            var cutPoint = await _uow.CutPointRepository.FindAsync(c => c.Points == request.Points);

            if (cutPoint != null)
            {
                throw new AlreadyExistsException("Cut point already exists");
            }

            cutPoint = new CutPoint
            {
                Points      = request.Points,
                Description = request.Description,
                IsActive    = false,
                CreatedAt   = DateTime.UtcNow,
                ModifiedAt  = DateTime.UtcNow
            };

            await _uow.CutPointRepository.AddAsync(cutPoint);

            await _uow.CommitAsync();

            return(cutPoint);
        }