/// <summary> /// Declaration of update employee method /// </summary> /// <param name="employee">passing employee model object</param> /// <returns>return boolean value</returns> public EmployeeModel UpdateEmployee(REmployeeModel employee) { try { if (employee != null) { var response = this.employeeRepositoryL.UpdateEmployee(employee); if (response != null) { return(response); } else { return(null); } } else { return(null); } } catch (Exception exception) { throw new Exception(exception.Message); } }
/// <summary> /// Define add employee data declaration /// </summary> /// <param name="employeeModel">passing employee model object</param> /// <returns>return boolean value</returns> public EmployeeModel AddEmployeeData(REmployeeModel employeeModel) { try { if (employeeModel != null) { if (employeeModel.Firstname == "" || employeeModel.Lastname == "" || employeeModel.CurrentAddress == "" || employeeModel.EmailId == "" || employeeModel.mobileNumber < 999999999 || employeeModel.Gender == "") { throw new CustomeException(CustomeException.ExceptionType.EMPTY_FIELD_EXCEPTION, "Empty Variable Field"); } else if (employeeModel.Firstname == null || employeeModel.Lastname == null || employeeModel.CurrentAddress == null || employeeModel.EmailId == null) { throw new CustomeException(CustomeException.ExceptionType.NULL_FIELD_EXCEPTION, "Empty Variable Field"); } var response = this.employeeRepositoryL.AddEmployee(employeeModel); if (response != null) { return(response); } else { return(null); } } else { return(null); } } catch (Exception exception) { throw new Exception(exception.Message); } }
public IActionResult AddEmployeeData(REmployeeModel employeeModel) { try { string cacheKey = "employees"; distributedCache.Remove(cacheKey); var responseMessage = this.employeeBusiness.AddEmployeeData(employeeModel); if (responseMessage != null) { bool Success = true; var Message = "Add Employee Data Sucessfully "; return(this.Ok(new { Success, Message, Data = responseMessage })); } else { bool Success = false; var Message = " Employee Insertion Failed "; return(this.BadRequest(new { Success, Message })); } } catch (Exception e) { bool Success = false; return(this.BadRequest(new { Success, message = e.Message })); } }
/// <summary> /// declaration of add employee method /// </summary> /// <param name="employeeModel">Passing employee model object</param> /// <returns>return boolean value</returns> public EmployeeModel AddEmployee(REmployeeModel employeeModel) { try { if (EmailChecking(employeeModel.EmailId)) { SqlCommand sqlCommand = new SqlCommand("spAddEmployeeData", this.sqlConnectionVariable); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@Firstname", employeeModel.Firstname); sqlCommand.Parameters.AddWithValue("@Lastname", employeeModel.Lastname); sqlCommand.Parameters.AddWithValue("@EmailID", employeeModel.EmailId); sqlCommand.Parameters.AddWithValue("@CurrentAddress", employeeModel.CurrentAddress); sqlCommand.Parameters.AddWithValue("@MobileNumber", employeeModel.mobileNumber); sqlCommand.Parameters.AddWithValue("@Gender", employeeModel.Gender); this.sqlConnectionVariable.Open(); //int response = sqlCommand.ExecuteNonQuery(); int status = 1; SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); while (sqlDataReader.Read()) { status = sqlDataReader.GetInt32(0); if (status == 1) { this.sqlConnectionVariable.Close(); return(GetSpecificEmployeeAllDetailes(employeeModel.EmailId)); } else { return(null); } } this.sqlConnectionVariable.Close(); } return(null); } catch (Exception exception) { throw new Exception(exception.Message); }finally { this.sqlConnectionVariable.Close(); } }