public bool Add(LeaveAddRequest newLeave) { try { return(_leaveRepository.Add(newLeave)); } catch (Exception ex) { throw ex; } }
public IActionResult Add([FromBody] LeaveAddRequest newLeave) { try { return(Ok(_leaveService.Add(newLeave))); } catch (Exception ex) { message = ex.Message; _log.LogError(message); return(StatusCode(StatusCodes.Status500InternalServerError, message)); } }
public bool Add(LeaveAddRequest newLeave) { try { SqlConnection sqlconn = new SqlConnection(connectionString); SqlCommand sqlComm = new SqlCommand("newLeave"); sqlconn.Open(); sqlComm.Connection = sqlconn; sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.AddWithValue("@leave", newLeave.Leave); SqlParameter returnParameter = sqlComm.Parameters.Add("RetVal", SqlDbType.Int); returnParameter.Direction = ParameterDirection.ReturnValue; sqlComm.ExecuteNonQuery(); sqlconn.Close(); return(true); } catch (Exception e) { throw e; } }