Beispiel #1
0
        public List <TransactionEntity> GetEmployeeList()
        {
            var empList = new List <TransactionEntity>();

            SqlDataReader reader = null;

            try
            {
                StoreProcedureCommand procedure = CreateProcedureCommand("dbo.GetEmployee");
                reader = ExecuteCommandAndReturnDataReader(procedure);

                while (reader.Read())
                {
                    empList.Add(new TransactionEntity {
                        EmpID = new Guid(reader["EmpID"].ToString()), Name = reader["Name"].ToString(), Address = reader["Address"].ToString(), EMail = reader["EMail"].ToString(), Phone = reader["Phone"].ToString()
                    });
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                reader.Close();
                throw ex;
            }

            return(empList);
        }
Beispiel #2
0
        public Result UpdateEmployee(TransactionEntity employeeData)
        {
            var result = new Result()
            {
                IsValid = false
            };

            StoreProcedureCommand procedure = CreateProcedureCommand("dbo.UpdateEmployee");

            procedure.AppendGuid("EmpID", employeeData.EmpID);
            procedure.AppendNVarChar("Address", employeeData.Address);
            procedure.AppendNVarChar("EMail", employeeData.EMail);
            procedure.AppendNVarChar("Phone", employeeData.Phone);

            int resultValue = ExecuteCommand(procedure);

            if (resultValue == 0)
            {
                result.IsValid = true;
                result.Message = new List <string> {
                    "Employee updated successfully"
                };
            }

            return(result);
        }
Beispiel #3
0
        public Result DeleteEmployee(Guid empID)
        {
            var result = new Result()
            {
                IsValid = false
            };

            StoreProcedureCommand procedure = CreateProcedureCommand("dbo.DeleteEmployee");

            procedure.AppendGuid("EmpID", empID);

            int resultValue = ExecuteCommand(procedure);

            if (resultValue == 0)
            {
                result.IsValid = true;
                result.Message = new List <string> {
                    "Employee deleted successfully"
                };
            }

            return(result);
        }