public IActionResult PostProduct(Products product) { try { if (ModelState.IsValid) { UserFunctions userFunctions = new UserFunctions(this._httpContextAccessor); product.UserId = userFunctions.GetUserId(); _productRepository.Insert(product); return(StatusCode((int)HttpStatusCode.Created, new { message = "Kayıt başarılıdır." })); } else { return(StatusCode((int)HttpStatusCode.BadRequest, new { message = "Bir hata oluştu." })); } } catch (Exception err) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = err })); } }