public async Task UpdateAsync(editDetails result) { using var cmd = Db.Connection.CreateCommand(); cmd.CommandText = @"UPDATE employee SET employee.salutationId=@salutation, employee.firstname = @firstName, employee.middlename=@middleName, employee.lastname=@lastName, employee.employeeGenderId=@gender where employee.employeeId=@id ; UPDATE address SET address.addressLine1= @addressLine1, address.addressLine2=@addressLine2, landmark=@locality WHERE address.employeeId=@id;"; BindParams(cmd, result.Id, result.salutation, result.firstName, result.MiddleName, result.lastName, result.gender); BindId(cmd, result.addressLine1, result.addressLine2, result.Locality); //bindParams cmd.CommandText = cmd.CommandText; await cmd.ExecuteNonQueryAsync(); }
public async Task <IActionResult> PutOne(int id, [FromBody] editDetails body) { await Db.Connection.OpenAsync(); var query = new employee(Db); var result = await query.FindOneAsync(id); if (result is null) { return(new NotFoundResult()); } result.Id = body.Id; result.salutation = body.salutation; result.firstName = body.firstName; result.MiddleName = body.MiddleName; result.lastName = body.lastName; result.gender = body.gender; result.addressLine1 = body.addressLine1; result.addressLine2 = body.addressLine2; result.Locality = body.Locality; await query.UpdateAsync(result); return(new OkObjectResult(result)); }
private async Task <List <editDetails> > readtwoAsync(DbDataReader reader) { var posts = new List <editDetails>(); // create an array of blogpost using (reader) { while (await reader.ReadAsync()) { var post = new editDetails() { Id = reader.GetInt32(0), salutation = reader.GetInt32(1), firstName = reader.GetString(2), MiddleName = reader.GetString(3), lastName = reader.GetString(4), addressLine1 = reader.GetString(5), addressLine2 = reader.GetString(6), Locality = reader.GetString(7) }; posts.Add(post); } } return(posts); }
private async Task <editDetails> readOneAsync(DbDataReader reader) { editDetails post; using (reader) { if (await reader.ReadAsync()) { post = new editDetails() { Id = reader.GetInt32(0), salutation = reader.GetInt32(1), firstName = reader.GetString(2), MiddleName = reader.GetString(3), lastName = reader.GetString(4), addressLine1 = reader.GetString(5), addressLine2 = reader.GetString(6), Locality = reader.GetString(7), }; return(post); } } return(null); }