public void AddEmployee_sp(EmpDTO Emp)
 {
     using (var empEntities = new EmployeeDBEntities())
     {
         var employee = Emp.ToEntity();
         empEntities.spAddEmployee(employee.Name,employee.JoinDate,employee.Salary,employee.DepartmentID);
     }
 }
 public int AddEmployee(EmpDTO Emp)
 {
     using (var empEntities = new EmployeeDBEntities())
     {
         var employee = Emp.ToEntity();
         empEntities.Employees.Add(employee);
         empEntities.SaveChanges();
         return employee.ID;
     }
 }
 public static EmpDTO ToDomain(this Employee emp)
 {
     var employee = new EmpDTO
     {
         Name = emp.Name,
         Salary = emp.Salary,
         JoinDate = emp.JoinDate,
         DepartmentID = emp.DepartmentID
     };
     return employee;
 }
 public void UpdateEmployee_sp(EmpDTO Emp)
 {
     using (var empEntities = new EmployeeDBEntities())
     {
         var employee = empEntities.Employees.FirstOrDefault(x => x.ID == Emp.ID);
         employee.JoinDate = Emp.JoinDate;
         employee.Name = Emp.Name;
         employee.Salary = Emp.Salary;
         employee.DepartmentID = Emp.DepartmentID;
         empEntities.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 private static void AddEmployee()
 {
     try
     {
         var emp = new EmpDTO
         {
             Name = "as",
             Salary = 20000,
             JoinDate = Convert.ToDateTime("04-05-1989"),
             DepartmentID = 2
         };
         obj.AddEmployee_sp(emp);
         Console.WriteLine("Added succesfully....");
         //Console.WriteLine(Id);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.ReadLine();
     }
 }
Ejemplo n.º 6
0
 private static void UpdateEmployee()
 {
     try
     {
         var emp = new EmpDTO
         {
             ID = 1004,
             Name = "as",
             Salary = 20000,
             JoinDate = Convert.ToDateTime("04-05-1989"),
             DepartmentID = 2
         };
         obj.UpdateEmployee(emp);
         Console.WriteLine("Updated succesfully....");
         Console.WriteLine(emp.ID);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.ReadLine();
     }
 }