public IActionResult UpdateAssignment([FromBody] MvAssignmentUpdate assignment) { try { var updated = _assignmentService.UpdateAssignment(assignment); if (!updated) { return(BadRequest()); } return(Ok()); } catch (Exception e) { throw e; } }
public bool UpdateAssignment(MvAssignmentUpdate assignment) { var jsonNew = JsonConvert.SerializeObject(assignment); using (var conn = _dah.GetConnection()) { using (var cmd = new SqlCommand("SpAssignmentUpd", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Json", SqlDbType.NChar).Value = jsonNew; cmd.CommandTimeout = int.Parse(_commandTimeout); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { return(true); } return(false); } } }
public bool UpdateAssignment(MvAssignmentUpdate assignmentUpdate) { using (var connection = _dataAccess.GetConnection()) { var jsonNew = JsonConvert.SerializeObject(assignmentUpdate); var command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "SpAssignmentUpd"; command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew; command.CommandTimeout = _commandTimeout; int rows = command.ExecuteNonQuery(); if (rows > 0) { return(true); } return(false); } }
public IActionResult UpdateAssignment([FromBody] MvAssignmentUpdate assignment) { if (!ModelState.IsValid) { return(BadRequest()); } try { var added = _assignmentService.UpdateAssignment(assignment); if (!added) { return(BadRequest()); } return(Ok()); } catch (Exception) { throw; } }