Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }