public ActionResult <ItemResponse <int> > Insert(MetaTagCreateRequest req) { ItemResponse <int> response = null; ActionResult result = null; int currentUserId = _authenticationService.GetCurrentUserId(); try { int id = _metaDataService.Insert(req, currentUserId); if (id > 0) { response = new ItemResponse <int>(); response.Item = id; result = Ok200(response); } else { result = NotFound404(new ErrorResponse("Error")); } } catch (Exception ex) { Logger.LogError(ex.ToString()); result = StatusCode(500, new ErrorResponse(ex.Message.ToString())); } return(result); }
public int Insert(MetaTagCreateRequest model, int userId) { int id = 0; _dataProvider.ExecuteNonQuery( "dbo.MetaTags_Insert", (paramCol) => { paramCol.AddWithValue("@Data", model.Data); paramCol.AddWithValue("@MetaTagTypeId", model.MetaTagTypeId); paramCol.AddWithValue("@CreatedBy", userId); SqlParameter idParameter = new SqlParameter("@Id", SqlDbType.Int); idParameter.Direction = ParameterDirection.Output; paramCol.Add(idParameter); }, (param) => { Int32.TryParse(param["@id"].Value.ToString(), out id); } ); return(id); }