Exemplo n.º 1
0
        public ActionResult GetRestrictionsByProductId(Guid id)
        {
            ResultWrapper <ProductReadDto> resultWrapper = _service.FindOne(id);

            ModelState.UpdateErrors(resultWrapper.GetErrors());

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            return(Ok(_service.GetRestrictionsByProductId(id)));
        }
Exemplo n.º 2
0
        public ActionResult Delete(Guid id)
        {
            ResultWrapper <ProductReadDto> resultWrapper = _service.DeleteById(id);

            ModelState.UpdateErrors(resultWrapper.GetErrors());

            if (!ModelState.IsValid)
            {
                return(NotFound(ModelState));
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public ActionResult Put(Guid id, [FromBody] ProductWriteDto writeDto)
        {
            ResultWrapper <ProductReadDto> resultWrapper = _service.UpdateElement(id, writeDto);

            ModelState.UpdateErrors(resultWrapper.GetErrors());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(resultWrapper.GetResult()));
        }
Exemplo n.º 4
0
        public ActionResult Post([FromBody] FinishWriteDto finishWriteDto)
        {
            ResultWrapper <FinishReadDto> result = _service.AddElement(finishWriteDto);

            ModelState.UpdateErrors(result.GetErrors());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Created($"api/finishes/{result.GetResult().Id}", result.GetResult()));
        }
Exemplo n.º 5
0
        public ActionResult GetById(Guid id)
        {
            ResultWrapper <FinishReadDto> resultWrapper = _service.FindOne(id);

            ModelState.UpdateErrors(resultWrapper.GetErrors());

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            return(Ok(resultWrapper.GetResult()));
        }
Exemplo n.º 6
0
        public ActionResult Post([FromBody] RestrictionWriteDto writeDto)
        {
            ResultWrapper <RestrictionReadDto> result = _service.AddElement(writeDto);

            ModelState.UpdateErrors(result.GetErrors());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            return(Created($"api/products/{result.GetResult().Id}", result.GetResult()));
        }