/// <summary> /// Gets all employee. /// </summary> /// <returns>ModelCL list</returns> public IEnumerable <ModelCL> GetAllEmployee() { IList <ModelCL> employees = new List <ModelCL>(); using (connection) { SqlCommand command = new SqlCommand("spGetEmployee", connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { ModelCL model = new ModelCL(); model.Id = (int)dataReader["Id"]; model.FirstName = dataReader["Firstname"].ToString(); model.LastName = dataReader["Lastname"].ToString(); model.Age = dataReader["Age"].ToString(); model.Email = dataReader["Email"].ToString(); model.EmployeeAddress = dataReader["EmployeeAddress"].ToString(); employees.Add(model); } connection.Close(); } return(employees); }
public string UpdateEmployee(ModelCL model) { if (model != null) { return(employeeRL.UpdateEmployee(model)); } else { return("Record is empty"); } }
public string Register(ModelCL model) { if (model != null) { return(employeeRL.Register(model)); } else { return("Record is empty"); } }
/// <summary> /// Registers the specified model. /// </summary> /// <param name="model">The model.</param> /// <returns>string</returns> public string Register(ModelCL model) { using (connection) { SqlCommand command = new SqlCommand("spInsertEmployee", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("FirstName", model.FirstName); command.Parameters.AddWithValue("LastName", model.LastName); command.Parameters.AddWithValue("Age", model.Age); command.Parameters.AddWithValue("Email", model.Email); command.Parameters.AddWithValue("EmployeeAddress", model.EmployeeAddress); connection.Open(); int result = command.ExecuteNonQuery(); if (result != 0) { return(model.FirstName + "'s record Registered SuccessFully"); } else { return("Data is not Registered"); } } }
public IActionResult UpdateEmployee(ModelCL model) { return(Ok(this.employeeBL.UpdateEmployee(model))); }
public IActionResult Register(ModelCL model) { return(Ok(this.employeeBL.Register(model))); }