/// <summary> /// It Stores Candidate Documents into the Database /// </summary> /// <param name="candidateID">CandidateID</param> /// <param name="documents">Candidate Documents</param> /// <returns>If Data Added Successully return ResponseData else null or BadRequest</returns> public CandidateDocumentsResponse AddCanndidateDocuments(int candidateID, CandidateDocumentsRequest documents) { try { CandidateDocumentsResponse responseData = null; try { using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { SqlCommand cmd = new SqlCommand("spAddCandidateDocuments", conn) { CommandType = System.Data.CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@CandidateID", candidateID); cmd.Parameters.AddWithValue("@DocType", documents.DocType); cmd.Parameters.AddWithValue("@DocPath", documents.DocPath); cmd.Parameters.AddWithValue("@Status", documents.Status); cmd.Parameters.AddWithValue("@CreatorStamp", documents.CreatorStamp); cmd.Parameters.AddWithValue("@CreatorUser", documents.CreatorUser); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now); conn.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { responseData = new CandidateDocumentsResponse() { ID = Convert.ToInt32(dataReader["ID"].ToString()), CandidateID = Convert.ToInt32(dataReader["CandidateID"].ToString()), DocType = dataReader["DocType"].ToString(), DocPath = dataReader["DocPath"].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 { return(null); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult AddDocuments(int candidateID, CandidateDocumentsRequest documents) { try { bool success = false; string message; var data = _fellowshipBusiness.AddCanndidateDocuments(candidateID, documents); if (data != null) { success = true; message = "Fellowship Candidate Documents 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 CandidateDocumentsResponse AddCanndidateDocuments(int candidateID, CandidateDocumentsRequest documents) { var responseData = _hiredRepository.AddCanndidateDocuments(candidateID, documents); return(responseData); }