public async Task <bool> Handle(UpdateEmployeeLastNameCommand request, CancellationToken cancellationToken)
            {
                var _entryToUpdate = dbContext.EmployeeInformation.Find(request.id);

                _entryToUpdate.LastName = request.newLastName;
                await dbContext.SaveChangesAsync();

                return(true);
            }
Esempio n. 2
0
            public async Task <bool> Handle(DeleteInfoCommand request, CancellationToken cancellationToken)
            {
                var _employeeToDelete = dbContext.EmployeeInformation.Find(request.id);

                dbContext.EmployeeInformation.Remove(_employeeToDelete);
                await dbContext.SaveChangesAsync();

                return(true);
            }
Esempio n. 3
0
            public async Task <bool> Handle(UpdateEmployeeAddressCommand request, CancellationToken cancellationToken)
            {
                var _employeeToUpdate = dbContext.EmployeeInformation.Find(request.id);

                _employeeToUpdate.Address = request.address;

                await dbContext.SaveChangesAsync();

                return(true);
            }
            public async Task <EmployeeInformation> Handle(SaveTimeOutCommand request, CancellationToken cancellationToken)
            {
                var _employeeToTimeOut = dbContext.EmployeeInformation.Find(request.id);

                EmployeeTimeRecords _timeRecord = new EmployeeTimeRecords
                {
                    EmployeeInformationID = _employeeToTimeOut.ID,
                    RecordType            = RecordType.TimeOut,
                    Time = DateTime.Now
                };

                dbContext.EmployeeTimeRecords.Add(_timeRecord);
                await dbContext.SaveChangesAsync();

                return(_employeeToTimeOut);
            }
            public async Task <int> Handle(SaveInfoCommand request, CancellationToken cancellationToken)
            {
                EmployeeInformation _employeeInformation = new EmployeeInformation
                {
                    FirstName   = request.employeeInformation.FirstName,
                    MiddleName  = request.employeeInformation.MiddleName,
                    LastName    = request.employeeInformation.LastName,
                    Address     = request.employeeInformation.Address,
                    DateOfBirth = request.employeeInformation.DateOfBirth,
                    Age         = request.employeeInformation.Age
                };

                //if (_employeeInformation.Age > 1)
                //{
                //    throw new Exception();
                //}


                dbContext.EmployeeInformation.Add(_employeeInformation);
                await dbContext.SaveChangesAsync();

                return(_employeeInformation.ID);
            }