public bool AssignLaptopToEmployee(int employeeId, int laptopId) { Employee ExistingEmployee = _employeeRepository.FindById(employeeId); Laptop ExistingLaptop = _laptopRepository.FindById(laptopId); if (ExistingEmployee == null || ExistingLaptop == null) { return(false); } ExistingEmployee.LaptopId = laptopId; _employeeRepository.Update(ExistingEmployee); _employeeRepository.SaveChanges(); ExistingLaptop.Employee = ExistingEmployee; _laptopRepository.Update(ExistingLaptop); _laptopRepository.SaveChanges(); return(true); }
public Laptop UpdateLaptop(int LaptopId, Laptop Laptop) { Laptop ExistingLaptop = _laptopRepository.FindById(LaptopId); if (ExistingLaptop == null) { return(null); } ExistingLaptop.Brand = Laptop.Brand; ExistingLaptop.CPU = Laptop.CPU; ExistingLaptop.Employee = Laptop.Employee; ExistingLaptop.OS = Laptop.OS; ExistingLaptop.RAM = Laptop.RAM; _laptopRepository.Update(ExistingLaptop); _laptopRepository.SaveChanges(); return(ExistingLaptop); }