/// <summary> /// It Stores Data in the Database /// </summary> /// <param name="labThreshold"></param> /// <returns>If Data Added Successfully return ResponseData else null or Exception</returns> public LabThresholdResponse AddLabThreshold(LabThresholdRequest labThreshold) { try { LabThresholdResponse responseData = null; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { SqlCommand cmd = new SqlCommand("spAddLabThreshold", conn) { CommandType = System.Data.CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@LabID", labThreshold.LabID); cmd.Parameters.AddWithValue("@LabCapacity", labThreshold.LabCapacity); cmd.Parameters.AddWithValue("@LeadThreshold", labThreshold.LeadThreshold); cmd.Parameters.AddWithValue("@IdeationEnggThreshold", labThreshold.IdeationEnggThreshold); cmd.Parameters.AddWithValue("@BuddyEnggThreshold", labThreshold.BuddyEnggThreshold); cmd.Parameters.AddWithValue("@Status", labThreshold.Status); cmd.Parameters.AddWithValue("@CreatorStamp", labThreshold.CreatorStamp); cmd.Parameters.AddWithValue("@CreatorUser", labThreshold.CreatorUser); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now); conn.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { responseData = new LabThresholdResponse() { ID = Convert.ToInt32(dataReader["ID"]), LabID = Convert.ToInt32(dataReader["LabID"]), LabCapacity = dataReader["LabCapacity"].ToString(), LeadThreshold = dataReader["LeadThreshold"].ToString(), IdeationEnggThreshold = dataReader["IdeationEnggThreshold"].ToString(), BuddyEnggThreshold = dataReader["BuddyEnggThreshold"].ToString(), Status = dataReader["Status"].ToString(), CreatorStamp = dataReader["CreatorStamp"].ToString(), CreatorUser = dataReader["CreatorUser"].ToString(), CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]), ModifiedDate = Convert.ToDateTime(dataReader["ModifiedDate"]) }; } conn.Close(); } return(responseData); } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult AddLabThreshold(LabThresholdRequest labThreshold) { try { bool success = false; string message; var data = _labBusiness.AddLabThreshold(labThreshold); if (data != null) { success = true; message = "LabThreshold Added Successfully"; return(Ok(new { success, message, data })); } else { message = "Try Again!"; return(NotFound(new { success, message })); } } catch (Exception ex) { return(BadRequest(new { ex.Message })); } }
public LabThresholdResponse AddLabThreshold(LabThresholdRequest labThreshold) { var responseData = _labRepository.AddLabThreshold(labThreshold); return(responseData); }