/// <summary> /// Add/ Update Employee /// </summary> /// <param name="Employees">The Employee model.</param> /// <returns>Employee Object</returns> public Employees AddUpdateEmployee(Employees employeeModel) { var employee = new Employees(); try { using (var dbCommand = MyDatabase.GetStoredProcCommand("AddUpdateEmployee")) { MyDatabase.AddInParameter(dbCommand, "@EmpId", DbType.Int64, employeeModel.EmpId); MyDatabase.AddInParameter(dbCommand, "@Name", DbType.String, employeeModel.Name); MyDatabase.AddInParameter(dbCommand, "@Designation", DbType.String, employeeModel.Designation); MyDatabase.AddInParameter(dbCommand, "@Email", DbType.String, employeeModel.Email); MyDatabase.AddInParameter(dbCommand, "@Phone", DbType.String, employeeModel.Phone); MyDatabase.AddInParameter(dbCommand, "@Address", DbType.String, employeeModel.Address); MyDatabase.AddInParameter(dbCommand, "@UserName", DbType.String, employeeModel.UserName); MyDatabase.AddInParameter(dbCommand, "@Password", DbType.String, employeeModel.Password); MyDatabase.AddInParameter(dbCommand, "@Age", DbType.Int32, employeeModel.Age); MyDatabase.AddOutParameter(dbCommand, "@p_Error", DbType.Int32, sizeof(Int32)); var dataSet = MyDatabase.ExecuteDataSet(dbCommand); // 50008--Error while updating Employee if (MyDatabase.GetParameterValue(dbCommand, "@p_Error").ToString() != "0") { var errorId = Convert.ToInt32(MyDatabase.GetParameterValue(dbCommand, "@p_Error")); employee.ErrorCode = errorId == 50008 ? "Error while updating Employee" : string.Empty; } else if (null != dataSet && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { var row = dataSet.Tables[0].Rows[0]; GetEmployeeInfo(employee, row); } } } catch (Exception ex) { employee.ErrorCode = ex.Message.ToString(); } return(employee); }