示例#1
0
 public List <Employee> GetAllEmployees()
 {
     try
     {
         String SqlQuery = "Select ID, Name, City, Address From Employees ";
         var    EmpList  = DBSqlContext.ReturnList <Employee>(SqlQuery);
         return(EmpList.ToList());
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
 }
示例#2
0
 //To delete Employee details
 public bool DeleteEmployee(int Id)
 {
     try
     {
         String SqlQuery = "Delete from Employee Where ID = @ID";
         DBSqlContext.ExecuteWithoutReturn(SqlQuery, new { ID = Id });
         return(true);
     }
     catch (Exception ex)
     {
         //Log error as per your need
         throw ex;
     }
 }
示例#3
0
        //To Update Employee details
        public bool UpdateEmployee(Employee employee)
        {
            try
            {
                String SqlQuery = "Update Employee set Name = @Name, City = @City,Address=@Address Where ID = @ID";
                DBSqlContext.ExecuteWithoutReturn(SqlQuery, new { employee.ID, employee.Name, employee.City, employee.Address });

                return(true);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
示例#4
0
 public bool AddEmployee(Employee employee)
 {
     //Additing the employess
     try
     {
         String SqlQuery = "Insert into Employee(Name, City, Address) values(@Name, @City,@Address)";
         DBSqlContext.ExecuteWithoutReturn(SqlQuery, new{ employee.Name, employee.City, employee.Address });
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }