public IActionResult UpdateCandidate(int candidateID, HiredUpdateRequest updateRequest) { try { bool success = false; string message; var data = _hiredBusiness.UpdateHired(candidateID, updateRequest); if (data != null) { success = true; message = "Candidate(Hired) Data Updated Successfully"; return(Ok(new { success, message, data })); } else { message = "Try Again!"; return(NotFound(new { success, message })); } } catch (Exception ex) { return(BadRequest(new { ex.Message })); } }
/// <summary> /// It Updates Data in the Database /// </summary> /// <param name="candidateID">CandidateID</param> /// <param name="hiredRegistrationUpdate">Hired Update Data</param> /// <returns>If Updating Data Successfull return ResponseData else return null or Exception</returns> public HiredResponseModel UpdateHired(int candidateID, HiredUpdateRequest hiredRegistrationUpdate) { try { HiredResponseModel responseData = null; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { SqlCommand cmd = new SqlCommand("spUpdateHired", conn) { CommandType = System.Data.CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@ID", candidateID); cmd.Parameters.AddWithValue("@HiredCity", hiredRegistrationUpdate.HiredCity); cmd.Parameters.AddWithValue("@HiredDate", DateTime.Now); cmd.Parameters.AddWithValue("@HiredLab", hiredRegistrationUpdate.HiredLab); cmd.Parameters.AddWithValue("@Attitude", hiredRegistrationUpdate.Attitude); cmd.Parameters.AddWithValue("@CommunicationRemark", hiredRegistrationUpdate.CommunicationRemark); cmd.Parameters.AddWithValue("@KnowledgeRemark", hiredRegistrationUpdate.KnowledgeRemark); cmd.Parameters.AddWithValue("@AggregateRemark", hiredRegistrationUpdate.AggregateRemark); cmd.Parameters.AddWithValue("@Status", hiredRegistrationUpdate.Status); cmd.Parameters.AddWithValue("@CreatorStamp", hiredRegistrationUpdate.CreatorStamp); cmd.Parameters.AddWithValue("@CreatorUser", hiredRegistrationUpdate.CreatorUser); cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now); conn.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { responseData = new HiredResponseModel { CandidateID = Convert.ToInt32(dataReader["ID"].ToString()), FirstName = dataReader["FirstName"].ToString(), MiddleName = dataReader["MiddleName"].ToString(), LastName = dataReader["LastName"].ToString(), Email = dataReader["Email"].ToString(), Degree = dataReader["Degree"].ToString(), MobileNumber = dataReader["MobileNumber"].ToString(), PermanentPincode = dataReader["PermanentPincode"].ToString(), HiredCity = dataReader["HiredCity"].ToString(), HiredDate = dataReader["HiredDate"].ToString(), HiredLab = dataReader["HiredLab"].ToString(), Attitude = dataReader["Attitude"].ToString(), CommunicationRemark = dataReader["CommunicationRemark"].ToString(), KnowledgeRemark = dataReader["KnowledgeRemark"].ToString(), AggregateRemark = dataReader["AggregateRemark"].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(); } if (responseData.Status.ToLower() == "accepted") { var isAddedToFellowship = AddSelectedFellowshipCandidate(responseData); if (isAddedToFellowship) { return(responseData); } return(null); } return(responseData); } catch (Exception ex) { throw new Exception(ex.Message); } }
public HiredResponseModel UpdateHired(int candidateID, HiredUpdateRequest hiredRegistrationUpdate) { var responseData = _hiredRepository.UpdateHired(candidateID, hiredRegistrationUpdate); return(responseData); }