コード例 #1
0
        public HttpResponseMessage GetEmployeeComputersByComputerId(int computerId)
        {
            var repo   = new ComputerRepository();
            var result = repo.GetAllByEmployeeComputersByComputerId(computerId);

            return(Request.CreateListRecordsResponse(result));
        }
コード例 #2
0
        public bool Delete(string dn, string samName)
        {
            ComputerRepository   ldapComputer = new ComputerRepository(_mySQLContext);
            CredentialRepository credential   = new CredentialRepository(_mySQLContext);
            Computer             result       = new Computer();

            credential.DN = dn;
            result        = ldapComputer.FindBySamName(credential, samName);
            try
            {
                if (result != null)
                {
                    return(ldapComputer.Delete(credential, result));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message);
                return(false);
            }
        }
 public EmployeeController(IConfiguration config)
 {
     EmployeeRepository.SetConfig(config);
     DepartmentRepository.SetConfig(config);
     ComputerRepository.SetConfig(config);
     _config = config;
 }
コード例 #4
0
 // GET: Computer
 public ActionResult Index()
 {
     {
         List <Computer> Computers = ComputerRepository.GetAllComputers();
         return(View(Computers));
     }
 }
        // GET: Employees/Create
        public ActionResult Create()
        {
            DepartmentRepository departmentRepo = new DepartmentRepository();
            var departments = departmentRepo.GetAllDepartments().Select(d => new SelectListItem
            {
                Text  = d.Name,
                Value = d.Id.ToString()
            }).ToList();

            ComputerRepository computerRepo = new ComputerRepository();
            var computers = computerRepo.GetAvailableComputers().Select(d => new SelectListItem
            {
                Text  = $"{d.Make} {d.Model}",
                Value = d.Id.ToString()
            }).ToList();


            var viewModel = new EmployeeCreateModel()
            {
                Employee    = new Employee(),
                Departments = departments,
                Computers   = computers
            };

            return(View(viewModel));
        }
コード例 #6
0
        public HttpResponseMessage GetCompuerById(int computerId)
        {
            var repo   = new ComputerRepository();
            var result = repo.GetComputer(computerId);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
コード例 #7
0
        public HttpResponseMessage ListComputers()
        {
            var             repo      = new ComputerRepository();
            List <Computer> computers = repo.GetAll();

            return(Request.CreateResponse(HttpStatusCode.OK, computers));
        }
コード例 #8
0
        public static IProductService GetProductService()
        {
            var computerRepository = new ComputerRepository();
            var tabletRepository   = new TabletRepository();
            var mouseRepository    = new MouseRepository();

            return(new ProductService(computerRepository, tabletRepository, mouseRepository));
        }
コード例 #9
0
ファイル: MainForm.cs プロジェクト: jeremyj563/SysTool
 public MainForm(ComputerRepository computerRepository) {
     this.InitializeComponent();
     this.ComputerRepository = computerRepository;
     this.BindingSource = new BindingSource();
     this.LDAPMonitor = new LDAPMonitor(computerRepository);
     this.LDAPMonitor.PropertyChanged += LDAPMonitor_PropertyChanged;
     this.CancellationTokenSource = new CancellationTokenSource();
 }
コード例 #10
0
        public HttpResponseMessage GetCustomers(CustomerModel customer)

        {
            var customers    = new ComputerRepository();
            var customerList = customers.Get();

            return(Request.CreateResponse(HttpStatusCode.Accepted, customerList));
        }
コード例 #11
0
        public HttpResponseMessage DeleteComputer(int computerId)
        {
            var repository = new ComputerRepository();
            var result     = repository.Delete(computerId);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not delete computer, please try again later."));
        }
コード例 #12
0
        public HttpResponseMessage AddComputer(Computer computer)
        {
            var repository = new ComputerRepository();
            var result     = repository.Create(computer);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.Created));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Customer could not be created, please try again later."));
        }
コード例 #13
0
        public HttpResponseMessage UpdateComputer(Computer computer, int computerId)
        {
            computer.ComputerId = computerId;
            var repository = new ComputerRepository();
            var result     = repository.Update(computer);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not update computer information, please try again later."));
        }
コード例 #14
0
 public ActionResult Create(Computer computer)
 {
     try
     {
         ComputerRepository.CreateComputer(computer);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
コード例 #15
0
 public ActionResult Delete(int id, Computer computer)
 {
     try
     {
         ComputerRepository.DeleteComputer(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
コード例 #16
0
        private bool Exist(string dn, string samName)
        {
            ComputerRepository ldapComputer = new ComputerRepository(_mySQLContext);

            if (ldapComputer.FindBySamName(dn, samName) != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #17
0
        public HttpResponseMessage CreateCustomer(CustomerModel customer)
        {
            var repository = new ComputerRepository();
            var result     = repository.CreateCustomer(customer);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.Created, "Customer has been created"));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError,
                                               "The customer didn't save, try again"));
        }
コード例 #18
0
 public UnitOfWork(ApplicationDataBaseContext applicationDataBaseContext)
 {
     _applicationDataBaseContext = applicationDataBaseContext;
     Computers            = new ComputerRepository(_applicationDataBaseContext);
     ComputerSystems      = new ComputerSystemRepository(_applicationDataBaseContext);
     Processors           = new ProcessorRepository(_applicationDataBaseContext);
     PhysicalMemories     = new PhysicalMemoryRepository(_applicationDataBaseContext);
     DiskDrives           = new DiskDriveRepository(_applicationDataBaseContext);
     MotherBoards         = new MotherBoardRepository(_applicationDataBaseContext);
     VideoCards           = new VideoCardRepository(_applicationDataBaseContext);
     Processes            = new ProcessRepository(_applicationDataBaseContext);
     ProcessesInformation = new ProcessInformationRepository(_applicationDataBaseContext);
     ProcessesPerfomance  = new ProcessPerfomanceRepository(_applicationDataBaseContext);
 }
コード例 #19
0
 public ComputerVO Update(ComputerVO computer)
 {
     try
     {
         ComputerRepository ldapComputer = new ComputerRepository(_mySQLContext);
         var computerEntity = _converter.Parse(computer);
         computerEntity = ldapComputer.Update(computerEntity);
         return(_converter.Parse(computerEntity));
     }
     catch (Exception e)
     {
         Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message);
         return(null);
     }
 }
コード例 #20
0
        private static void FindComputer(string computerName)
        {
            var computerRepository = new ComputerRepository();

            ComputerBase computer = computerRepository.Find(computerName);

            if (computer != ComputerBase.Null)
            {
                computer.Start();
                computer.Stop();
            }
            else
            {
                Console.WriteLine("Computer not found!");
            }
        }
コード例 #21
0
        public void SaveComputerToDB(Computer computer)
        {
            computer.LastUsage = DateTime.Now;

            var repository = new ComputerRepository();
            var computerDB = repository.FindByName(computer.Name);

            if (computerDB == null)
            {
                AddComputer(computer, repository);
            }
            else
            {
                UpdateComputer(computer, repository, computerDB);
            }
        }
コード例 #22
0
        public HttpResponseMessage MakeInactive(int id)
        {
            var customerRepository = new ComputerRepository();
            var getSingleCustomer  = customerRepository.GetSingle(id);

            if (!getSingleCustomer)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Could not find customer"));
            }
            else if (customerRepository.IsInactive(id))
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Cannot make customer inactive at this time. Try again later."));
            }
        }
コード例 #23
0
        protected override Order NewRecord(IDataReader reader)
        {
            var order = new Order
            {
                Id            = ConvertReader <int> .WithName(reader, "id"),
                DateRequested = ConvertReader <DateTime> .WithName(reader, "DateRequested"),
                DateDelivered = ConvertReader <DateTime> .WithName(reader, "DateDelivered"),
                Employee      = EmployeeRepository.GetByName(ConvertReader <string> .WithName(reader, "Email_Employee")),
                Client        = ClientRepository.GetByEmail(ConvertReader <string> .WithName(reader, "Email_client")),
                Commentary    = ConvertReader <string> .WithName(reader, "Commentary"),
                State         = ConvertReader <OrderState> .WithName(reader, "OrderState")
            };

            foreach (var computer in ComputerRepository.GetByOrder(ConvertReader <int> .WithName(reader, "id")).ToList())
            {
                order.Add(computer);
            }
            return(order);
        }
        // GET: Employees/Details/5
        public ActionResult Details(int id)
        {
            EmployeeRepository employeeRepo = new EmployeeRepository();
            var employee = employeeRepo.GetEmployeeById(id);
            DepartmentRepository departmentRepo = new DepartmentRepository();
            var department = departmentRepo.GetDepartmentById(employee.DepartmentId);
            ComputerRepository computerRepo = new ComputerRepository();
            var computer = computerRepo.GetComputerById(employee.ComputerId);
            TrainingProgramRepository trainingProgramRepo = new TrainingProgramRepository();
            List <TrainingProgram>    trainingPrograms    = trainingProgramRepo.GetTrainingProgramsByEmployeeId(id);

            var viewModel = new EmployeeDetailsModel()
            {
                Employee         = employee,
                Department       = department,
                Computer         = computer,
                TrainingPrograms = trainingPrograms
            };

            return(View(viewModel));
        }
        public EmployeeEditViewModel(int EmployeeId)
        {
            // When we create a new instance of this view model, we'll call the internal methods to get all the cohorts from the database
            // Then we'll map over them and convert the list of cohorts to a list of select list items

            //Query the database to get all departments

            Employee = EmployeeRepository.GetOneEmployee(EmployeeId);

            Departments = DepartmentRepository.GetAllDepartments()
                          .Select(department => new SelectListItem()
            {
                Text  = department.Name,
                Value = department.Id.ToString()
            })
                          .ToList();

            // Add an option with instructions for how to use the dropdown
            Departments.Insert(0, new SelectListItem
            {
                Text  = "Choose a department",
                Value = "0"
            });

            //Query the database to get all computers
            Computers = ComputerRepository.GetAllComputers()
                        .Select(computer => new SelectListItem()
            {
                Text  = computer.Manufacturer + " " + computer.Make,
                Value = computer.Id.ToString(),
            })
                        .ToList();

            // Add an option with instructions for how to use the dropdown
            Computers.Insert(0, new SelectListItem
            {
                Text  = "Choose a computer",
                Value = "0"
            });
        }
コード例 #26
0
 private static void AddComputer(Computer computer, ComputerRepository repository)
 {
     repository.Add(computer);
 }
コード例 #27
0
        private static void UpdateComputer(Computer computer, ComputerRepository repository, Computer computerDB)
        {
            computerDB.LastUsage = computer.LastUsage;
            computerDB.Chassis   = computer.Chassis;
            computerDB.DecodedWindowsProductKey = computer.DecodedWindowsProductKey;
            computerDB.Manufacturer             = computer.Manufacturer;
            computerDB.Model                      = computer.Model;
            computerDB.Motherboard                = computer.Motherboard;
            computerDB.Name                       = computer.Name;
            computerDB.PhysicalMemory             = computer.PhysicalMemory;
            computerDB.SerialNumber               = computer.SerialNumber;
            computerDB.UndecodedWindowsProductKey = computer.UndecodedWindowsProductKey;
            computerDB.UserName                   = computer.UserName;

            computerDB.Bios.BiosDate         = computer.Bios.BiosDate;
            computerDB.Bios.BiosManufacturer = computer.Bios.BiosManufacturer;
            computerDB.Bios.BiosVersion      = computer.Bios.BiosVersion;

            computerDB.OperatingSystem.OSArchitecture = computer.OperatingSystem.OSArchitecture;
            computerDB.OperatingSystem.OSBuild        = computer.OperatingSystem.OSBuild;
            computerDB.OperatingSystem.OSInstallDate  = computer.OperatingSystem.OSInstallDate;
            computerDB.OperatingSystem.OSManufacturer = computer.OperatingSystem.OSManufacturer;
            computerDB.OperatingSystem.OSName         = computer.OperatingSystem.OSName;
            computerDB.OperatingSystem.OSSerialNumber = computer.OperatingSystem.OSSerialNumber;
            computerDB.OperatingSystem.OSVersion      = computer.OperatingSystem.OSVersion;

            computerDB.Processor.ProcessorArchitecture              = computer.Processor.ProcessorArchitecture;
            computerDB.Processor.ProcessorManufacturer              = computer.Processor.ProcessorManufacturer;
            computerDB.Processor.ProcessorName                      = computer.Processor.ProcessorName;
            computerDB.Processor.ProcessorNumberOfCores             = computer.Processor.ProcessorNumberOfCores;
            computerDB.Processor.ProcessorNumberOfLogicalProcessors = computer.Processor.ProcessorNumberOfLogicalProcessors;

            computerDB.Disks
            .Where(x => !computer.Disks.Any(y => y.Name == x.Name))
            .ToList()
            .ForEach(x => x.RemovedDate = DateTime.Now);

            computer.Disks.ForEach(d =>
            {
                if (computerDB.Disks.Any(x => x.Name == d.Name))
                {
                    var existingDisk = computerDB.Disks.Single(x => x.Name == d.Name);

                    existingDisk.Manufacturer = d.Manufacturer;
                    existingDisk.SerialNumber = d.SerialNumber;
                    existingDisk.Size         = d.Size;
                    existingDisk.RemovedDate  = null;
                }
                else
                {
                    computerDB.Disks.Add(d);
                }
            });

            computerDB.LogicalDrives
            .Where(x => !computer.LogicalDrives.Any(y => y.Name == x.Name))
            .ToList()
            .ForEach(x => x.RemovedDate = DateTime.Now);

            computer.LogicalDrives.ForEach(ld =>
            {
                if (computerDB.LogicalDrives.Any(x => x.Name == ld.Name))
                {
                    var existingDrive = computerDB.LogicalDrives.Single(x => x.Name == ld.Name);

                    existingDrive.Size         = ld.Size;
                    existingDrive.FileSystem   = ld.FileSystem;
                    existingDrive.SerialNumber = ld.SerialNumber;
                    existingDrive.FreeSpace    = ld.FreeSpace;
                    existingDrive.RemovedDate  = null;
                }
                else
                {
                    computerDB.LogicalDrives.Add(ld);
                }
            });

            computerDB.NetworkAdapters
            .Where(x => !computer.NetworkAdapters.Any(y => y.Name == x.Name))
            .ToList()
            .ForEach(x => x.RemovedDate = DateTime.Now);

            computer.NetworkAdapters.ForEach(na =>
            {
                if (computerDB.NetworkAdapters.Any(x => x.Name == na.Name))
                {
                    var existingAdapter = computerDB.NetworkAdapters.Single(x => x.Name == na.Name);

                    existingAdapter.MACAddress      = na.MACAddress;
                    existingAdapter.Manufacturer    = na.Manufacturer;
                    existingAdapter.NetConnectionID = na.NetConnectionID;
                    existingAdapter.NetEnabled      = na.NetEnabled;
                    existingAdapter.RemovedDate     = null;
                }
                else
                {
                    computerDB.NetworkAdapters.Add(na);
                }
            });

            computerDB.Softwares
            .Where(x => !computer.Softwares.Any(y => y.Name == x.Name && y.Publisher == x.Publisher && y.Version == x.Version && y.Type == x.Type))
            .ToList()
            .ForEach(x => x.RemovedDate = DateTime.Now);

            computer.Softwares.ForEach(s =>
            {
                if (computerDB.Softwares.Any(x => s.Name == x.Name && s.Publisher == x.Publisher && s.Version == x.Version && s.Type == x.Type))
                {
                    var existingSoftware = computerDB.Softwares.Single(x => s.Name == x.Name && s.Publisher == x.Publisher && s.Version == x.Version && s.Type == x.Type);

                    existingSoftware.InstallDate = s.InstallDate;
                    existingSoftware.RemovedDate = null;
                }
                else
                {
                    computerDB.Softwares.Add(s);
                }
            });

            repository.Update(computerDB);
        }
コード例 #28
0
 public ComputerController()
 {
     this.computerRepository = new ComputerRepository();
 }
コード例 #29
0
 public ProductsService()
 {
     _computerRepository = new ComputerRepository();
     _tabletRepository   = new TabletRepository();
 }
コード例 #30
0
        // GET: Product
        public ActionResult Index()
        {
            ComputerRepository sql = new ComputerRepository();

            return(Json(sql.GetComputers(), JsonRequestBehavior.AllowGet));
        }