public ActionResult <ItemResponse <int> > Insert(AdvertisementDocumentAddRequest model) { try { int id = _advertisementDocumentService.Insert(model, _authService.GetCurrentUserId()); ItemResponse <int> response = new ItemResponse <int>(); response.Item = id; return(Created201(response)); } catch (Exception ex) { Logger.LogError(ex.ToString()); return(StatusCode(500, new ErrorResponse(ex.Message))); } }
public int Insert(AdvertisementDocumentAddRequest model, int userId) { int adId = 0; _dataProvider.ExecuteNonQuery( "dbo.AdvertisementDocuments_Insert", inputParamMapper : delegate(SqlParameterCollection paramCol) { paramCol.AddWithValue("@EventId", model.EventId); paramCol.AddWithValue("@Name", model.Name); paramCol.AddWithValue("@DocumentUrl", model.DocumentUrl.ToString()); paramCol.AddWithValue("@CreatedBy", userId); SqlParameter paramId = new SqlParameter("@Id", System.Data.SqlDbType.Int); paramId.Direction = System.Data.ParameterDirection.Output; paramCol.Add(paramId); }, returnParameters : delegate(SqlParameterCollection param) { Int32.TryParse(param["@Id"].Value.ToString(), out adId); } ); return(adId); }