public Employee SearchForAnEmployee(string employeeName) { using (businessContext = new BusinessProjectDbContext()) { return(businessContext.Employees.First(x => x.Name == employeeName)); } }
public void RemoveDepartment(string depName) { using (businessContext = new BusinessProjectDbContext()) { //List<Employee> empList = new List<Employee>(); var result = (from r in businessContext.Employees select r).ToList(); foreach (var emp in result) { if (emp.Dep == businessContext.Departments.FirstOrDefault(x => x.Name == depName)) { emp.Dep = businessContext.Departments.First(x => x.Name == "TemporaryDepartment"); businessContext.SaveChanges(); } } //foreach (var el in empList) //{ // businessContext.Employees.Add(el); // businessContext.SaveChanges(); //} businessContext.Departments.Remove(businessContext.Departments.FirstOrDefault(x => x.Name == depName)); businessContext.SaveChanges(); } }
public Employee GetEmployeeByName(string employeeName) { using (businessContext = new BusinessProjectDbContext()) { return(businessContext.Employees.Where(x => x.Name == employeeName) .Include(x => x.Dep).FirstOrDefault()); } }
public void RemoveEmployee(Employee employeeForRemoving) { using (businessContext = new BusinessProjectDbContext()) { businessContext.Employees.Remove(employeeForRemoving); businessContext.SaveChanges(); } }
public void RemoveEmployeeById(int id) { using (businessContext = new BusinessProjectDbContext()) { businessContext.Employees.Remove(businessContext.Employees.FirstOrDefault(x => x.EmployeeId == id)); businessContext.SaveChanges(); } }
public void AddEmployee(string name, int year, FamilyStatus famStatus, int internship, string departmentName) { using (businessContext = new BusinessProjectDbContext()) { Employee newEmployee = new Employee(name, year, famStatus, internship, businessContext.Departments.First(x => x.Name == departmentName)); businessContext.Employees.Add(newEmployee); businessContext.SaveChanges(); } }
public bool EmployeeSalaryValidation(string salary, Department d) { using (businessContext = new BusinessProjectDbContext()) { if (int.Parse(salary) < d.BaseSalary) { return(false); } } return(true); }
public void ReworkEmployee(Employee foundEmployee, string name, int year, FamilyStatus fStat, int internship, string depName, double salary) { using (businessContext = new BusinessProjectDbContext()) { businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Name = name; businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Year = year; businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Status = fStat; businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Internship = internship; businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Dep = businessContext.Departments.First(x => x.Name == depName); businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId).Salary = salary; businessContext.SaveChanges(); } }
public bool CheckIfTheEmployeeExists(string EmployeeName) { using (businessContext = new BusinessProjectDbContext()) { try { string gettingTheName = businessContext.Employees.First(x => x.Name == EmployeeName).Name; return(true); } catch (Exception) { return(false); } } }
public void ReworkEmployee(Employee foundEmployee, string name, int year, FamilyStatus fStat, int internship, Department dep, double salary) { using (businessContext = new BusinessProjectDbContext()) { Employee employee = businessContext.Employees.First(x => x.EmployeeId == foundEmployee.EmployeeId); employee.Name = name; employee.Year = year; employee.Status = fStat; employee.Internship = internship; employee.Dep = dep; employee.Salary = salary; businessContext.SaveChanges(); } }