public HttpResponseMessage Insert([FromBody] SORType SORType) { _SORTypeRepo.InsertSORTypeDetailsAsync(SORType); var message = Request.CreateResponse(HttpStatusCode.Created, SORType); message.Headers.Location = new Uri(Request.RequestUri + SORType.ID.ToString()); return(message); }
public void InsertSORTypeDetailsAsync(SORType SORType) { if (myconn.State != ConnectionState.Open) { myconn.Open(); } SORType.createdDate = DateTime.Now; SORType.modifiedDate = DateTime.Now; SqlTransaction tran = myconn.BeginTransaction(); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.CommandText = "SP_SORTypeInsertUpdate"; sqlCmd.Parameters.Add(new SqlParameter("@mode", "I")); sqlCmd.Parameters.Add(new SqlParameter("@Id", SORType.ID)); sqlCmd.Parameters.Add(new SqlParameter("@name", SORType.name)); sqlCmd.Parameters.Add(new SqlParameter("@createdDate", SORType.createdDate)); sqlCmd.Parameters.Add(new SqlParameter("@modifiedDate", SORType.modifiedDate)); sqlCmd.Parameters.Add(new SqlParameter("@userId", SORType.userId)); try { sqlCmd.Connection = myconn; sqlCmd.Transaction = tran; SORType.ID = Convert.ToInt32(sqlCmd.ExecuteScalar()); tran.Commit(); } catch (Exception ex) { tran.Rollback(); gs.LogData(ex); throw ex; } finally { if (myconn.State != ConnectionState.Closed) { myconn.Close(); } } }
public async Task <List <SORType> > Update([FromBody] SORType SORType) { List <SORType> lst = await Task.Run(() => _SORTypeRepo.UpdateSORTypeDetailsAsync(SORType)); return(lst); }