public HttpResponseMessage CreateWorkHistory([FromBody] WorkHistoryAddRequest payload) { try { ItemResponse <int> response = new ItemResponse <int>(); response.Item = _workHistoryService.WorkHistoryInsert(payload); return(Request.CreateResponse(response)); } catch (Exception ex) { ErrorLogService svc = new ErrorLogService(); ErrorLogAddRequest error = new ErrorLogAddRequest(); error.ErrorFunction = "Aic.Web.Controllers.Api.CreateWorkHistory"; error.ErrorMessage = ex.Message; error.UserId = UserService.UserSelect().PersonId; svc.ErrorLogInsert(error); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } } // CreateWorkHistory
public int WorkHistoryInsert(WorkHistoryAddRequest payload) { int id = 0; DataProvider.ExecuteNonQuery(GetConnection, "dbo.WorkHistory_Upsert" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@PersonID", payload.PersonID); paramCollection.AddWithValue("@CompanyID", payload.CompanyID); paramCollection.AddWithValue("@Company", payload.Company); paramCollection.AddWithValue("@Title", payload.Title); paramCollection.AddWithValue("@Contract", payload.Contract); paramCollection.AddWithValue("@Datestarted", payload.DateStarted.ToShortDateString()); // .Date if (payload.DateEnded.HasValue) { paramCollection.AddWithValue("@DateEnded", payload.DateEnded.Value.Date); } else { // send dbnull paramCollection.AddWithValue("@DateEnded", System.DBNull.Value); }; paramCollection.AddWithValue("@Description", payload.Description); SqlParameter w = new SqlParameter("@ID", System.Data.SqlDbType.Int); w.Direction = System.Data.ParameterDirection.Output; paramCollection.Add(w); }, returnParameters : delegate(SqlParameterCollection paramCollection) { int.TryParse(paramCollection["@ID"].Value.ToString(), out id); } ); return(id); } // WorkHistoryInsert