public IActionResult CreateClothes([FromBody] Clothes clothes) { try { if (clothes.IsEntityNull()) { return(BadRequest("Clothes object is null")); } if (!clothes.IsEntityEmpty()) { return(BadRequest("For create, the Id must be null")); } if (!ModelState.IsValid) { return(BadRequest("Invalid model object")); } _clothesService.CreateClothes(clothes); _clothesService.Save(); return(CreatedAtRoute("ClothesById", new { id = clothes.Id.Value }, clothes)); } catch (Exception ex) { _logger.Error(ex, "Error in call : api/clothes/CreateClothes", clothes); return(StatusCode(StatusCodes.Status500InternalServerError, "Internal server error")); } }