Пример #1
0
 public IActionResult Put([FromBody] ProductCreateInputModel model)
 {
     try
     {
         ProductControllerHelperMethods.ValidModel(model, false);
         _IProductService.EditProduct(model);
     }
     catch (Exception e)
     {
         return(SendRightStatus(e));
     }
     return(Ok());
 }
Пример #2
0
 public IActionResult Delete(Guid id)
 {
     try
     {
         ProductControllerHelperMethods.ValidIdProperty(id);
         _IProductService.RemoveProduct(id);
     }
     catch (Exception e)
     {
         return(SendRightStatus(e));
     }
     return(NoContent());
 }
Пример #3
0
        public ActionResult <Guid> Post([FromBody] ProductCreateInputModel model)
        {
            Guid idOfCreatedObject = new Guid();

            try
            {
                ProductControllerHelperMethods.ValidModel(model, true);
                idOfCreatedObject = _IProductService.SetProduct(model);
            }
            catch (Exception e)
            {
                return(SendRightStatus(e));
            }
            return(StatusCode(StatusCodes.Status201Created, idOfCreatedObject));
        }
Пример #4
0
        public ActionResult <ProductCreateInputModel> Get(Guid id)
        {
            ProductCreateInputModel valueResult = null;

            try
            {
                ProductControllerHelperMethods.ValidIdProperty(id);
                valueResult = _IProductService.GetProduct(id);
            }
            catch (Exception e)
            {
                return(SendRightStatus(e));
            }

            return(Ok(valueResult));
        }