Ejemplo n.º 1
0
        // GET: Employee
        public ActionResult Index()
        {
            EmployeeModel model = new EmployeeModel();
            DataTable     dt    = model.GetAllEmployees();

            return(View("Home", dt));
        }
        public void Login(string username, string password, LoginView view)
        {
            List <Employee> employees = empmod.GetAllEmployees();

            if (username == "Master" && password == "Master")
            {
                OwnerView ov = new OwnerView();
                view.Close();
                ov.Show();
            }
            else if (employees.Contains((from e in employees where e.Username == username && e.Password == password select e).FirstOrDefault()))
            {
                Employee employee = (from e in employees where e.Username == username && e.Password == password select e).FirstOrDefault();
                if (employee.Responsibility != null)
                {
                    WorkerView wv = new WorkerView();
                    view.Close();
                    wv.Show();
                }
                else
                {
                    ManagerView mv = new ManagerView();
                    view.Close();
                    mv.Show();
                }
            }
            else
            {
                MessageBox.Show("Username or Password was incorrect ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public UpdateEmployeeViewModel(UpdateEmployeeView updateEmployeeOpen, Employee updateEmployee)
        {
            employee           = updateEmployee;
            updateEmployeeView = updateEmployeeOpen;

            LocationList = locModel.GetAllLocations();
            SectorList   = secModel.GetAllSectors();
            EmployeeList = empModel.GetAllEmployees();
            location     = updateEmployee.Location;
            sector       = updateEmployee.Sector;

            bw.DoWork             += DoWork;
            bw.RunWorkerCompleted += WorkCompleted;
        }
Ejemplo n.º 4
0
        public AddEmployeeViewModel(AddEmployeeView addEmployeeOpen)
        {
            employee        = new Employee();
            location        = new Location();
            sector          = new Sector();
            addEmployeeView = addEmployeeOpen;

            LocationList = locModel.GetAllLocations();
            SectorList   = secModel.GetAllSectors();
            EmployeeList = empModel.GetAllEmployees();

            bw.DoWork             += DoWork;
            bw.RunWorkerCompleted += WorkCompleted;
        }
Ejemplo n.º 5
0
        public ActionResult GetEmployees()
        {
            EmployeeModel employeeObj = new EmployeeModel();
            EmployeeDTO   objDTO      = new EmployeeDTO();

            try
            {
                employeeObj = new EmployeeModel(_dataAccess);
                var empList = employeeObj.GetAllEmployees();
                objDTO.employeeList = empList;
                return(View("GetEmployees", objDTO));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Retrieve all the employees in a list
        public List <EmployeeViewModel> GetAll()
        {
            List <EmployeeViewModel> allVms = new List <EmployeeViewModel>();

            try
            {
                //Get a list of all the employees and use each employee in that list to create a view model and then return the list of view model objects
                List <Employee> allEmps = _model.GetAllEmployees();
                foreach (Employee emp in allEmps)
                {
                    EmployeeViewModel empVm = new EmployeeViewModel();
                    empVm.Title          = emp.Title;
                    empVm.Firstname      = emp.FirstName;
                    empVm.Lastname       = emp.LastName;
                    empVm.Phoneno        = emp.PhoneNo;
                    empVm.Email          = emp.Email;
                    empVm.Id             = emp.Id;
                    empVm.DepartmentId   = emp.DepartmentId;
                    empVm.DepartmentName = emp.Department.DepartmentName;
                    empVm.Timer          = Convert.ToBase64String(emp.Timer);
                    empVm.isTech         = emp.IsTech;

                    if (emp.StaffPicture != null)
                    {
                        empVm.StaffPicture64 = Convert.ToBase64String(emp.StaffPicture);
                    }
                    allVms.Add(empVm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Problem in " + GetType().Name + " " + MethodBase.GetCurrentMethod().Name + " " + ex.Message);
                throw ex;
            }
            return(allVms);
        }
 public OwnerViewModel(OwnerView v)
 {
     employeeList = empMod.GetAllEmployees();
     view         = v;
 }
 public void EmployeeModelGetAllShouldReturnList()
 {
     EmployeeModel model = new EmployeeModel();
     List<Employee> allEmps = model.GetAllEmployees();
     Assert.IsTrue(allEmps.Count > 0);
 }