public EmployeesWindow()
        {
            InitializeComponent();
            Left = SystemParameters.VirtualScreenWidth / 2 - Width / 2 + Width / 4;
            Top  = SystemParameters.VirtualScreenHeight / 2 - Height / 2 + Width / 4;
            EmployeesViewModel eVM = (EmployeesViewModel)this.DataContext;

            eVM.PropertyChanged += (s, eArgs) =>
            {
                if (eVM.NeedAuthentication)
                {
                    LoginWindow loginWindow = new LoginWindow();
                    loginWindow.ShowDialog();
                }

                if (eArgs.PropertyName == "MessageBoxVM")
                {
                    switch (MessageBox.Show(eVM.MessageBoxVM.Message,
                                            eVM.MessageBoxVM.Caption,
                                            eVM.MessageBoxVM.Buttons))
                    {
                    case MessageBoxResult.Cancel:
                    {
                        eVM.MessageBoxVM.Result = MessageBoxResult.Cancel;
                        break;
                    }

                    case MessageBoxResult.No:
                    {
                        eVM.MessageBoxVM.Result = MessageBoxResult.No;
                        break;
                    }

                    case MessageBoxResult.None:
                    {
                        eVM.MessageBoxVM.Result = MessageBoxResult.None;
                        break;
                    }

                    case MessageBoxResult.Yes:
                    {
                        eVM.MessageBoxVM.Result = MessageBoxResult.Yes;
                        break;
                    }

                    default: break;
                    }
                }
            };
        }
Exemplo n.º 2
0
        public ActionResult Create(EmployeesViewModel model)
        {
            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            Employees emp = new Employees();

            emp.Id_Employee       = model.Id_Employee;
            emp.FirstName         = model.FirstName;
            emp.LastName          = model.LastName;
            emp.PhoneNumber       = model.PhoneNumber;
            emp.EmailAddress      = model.EmailAddress;
            emp.EmployeeReference = model.EmployeeReference;
            emp.DeletedAt         = model.DeletedAt;
            emp.Active            = model.Active;
            emp.EmployeePicture   = model.EmployeePicture;

            db.Employees.Add(emp);

            int contractorId = int.Parse(model.CompanyName);

            if (contractorId > 0)
            {
                Contractors con = db.Contractors.Find(contractorId);
                emp.Id_Contractor = con.Id_Contractor;
            }

            int departmentId = int.Parse(model.DepartmentName);

            if (departmentId > 0)
            {
                Departments dep = db.Departments.Find(departmentId);
                emp.Id_Department = dep.Id_Department;
            }

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            ViewBag.DepartmentName = new SelectList((from d in db.Departments select new { Id_Department = d.Id_Department, DepartmentName = d.DepartmentName }), "Id_Department", "DepartmentName", null);

            ViewBag.CompanyName = new SelectList((from c in db.Contractors select new { Id_Contractor = c.Id_Contractor, CustomerName = c.CompanyName }), "Id_Contractor", "CompanyName", null);

            return(RedirectToAction("Index"));
        }//create
Exemplo n.º 3
0
		public JsonNetResult GetOrganisations(EmployeeFilter employeeFilter)
        {
            var employeesViewModel = new EmployeesViewModel();
            employeesViewModel.Initialize(employeeFilter);

            dynamic result = new
            {
                page = 1,
                total = 100,
                records = 100,
                rows = employeesViewModel.Organisations,
            };

            return new JsonNetResult { Data = result };
        }
Exemplo n.º 4
0
        public ActionResult SearchEmployeeByName(string name)
        {
            List <EmployeesListViewModel> employeesListViewModel = new List <EmployeesListViewModel>();

            if (ModelState.IsValid)
            {
                var employeeList = _employeeService.GetEmployeeByName(name);
                Mapper.Map(employeeList, employeesListViewModel);
            }
            var employees = new EmployeesViewModel {
                Employees = employeesListViewModel, SearchCriteria = new EmployeeSearchCriteriaViewModel()
            };

            return(View("GetAllEmployeesList", employees));
        }
Exemplo n.º 5
0
        public IActionResult Index(string searchPhrase)
        {
            IQueryable <Employee> employees = _context.Employees;

            if (!string.IsNullOrWhiteSpace(searchPhrase))
            {
                employees = employees.Where(x => x.LastName.Contains(searchPhrase) || x.City.Contains(searchPhrase));
            }

            var vm = new EmployeesViewModel
            {
                Employees = employees.ToArray()
            };

            return(View(vm));
        }
        public IActionResult UpdateEmployee([FromBody] EmployeesViewModel model)
        {
            try
            {
                var empDomain = Service <IEmployeesDomain>();
                var result    = empDomain.UpdateEmployees(model);

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(StatusCode(500, new ResponseViewModel {
                    Message = e.Message, Success = false
                }));
            }
        }
Exemplo n.º 7
0
    public ActionResult Employee(EmployeesViewModel model)
    {
        SetEquipmentData(model);
        SetOfficeData(model);
        // remove properties from modelstate in order to get modified values in view
        ModelState.Remove("Name");
        ModelState.Remove("Phone");
        ModelState.Remove("Email");
        //SHOULD GET EMPLOYEE DATA FROM DB BASED ON UserID PROPERTY

        // dummy data:
        model.Name  = "John Doe";
        model.Phone = "973-548-85965";
        model.Email = "*****@*****.**";
        return(View(model));
    }
Exemplo n.º 8
0
        public async Task <IActionResult> Index(string name, string jobTitle, string department, DateTime?joinedOn)
        {
            var searchedCriteria = new EmployeesViewModel
            {
                Name       = name,
                JobTitle   = jobTitle,
                Department = department,
                JoinedOn   = joinedOn,
            };
            var model = new EmployeesListModel
            {
                Employees = (await this.employeeService.GetBySearchCriteriaAsync <EmployeesViewModel>(searchedCriteria)).ToHashSet(),
            };

            return(this.View(model));
        }
        public IActionResult Index()
        {
            try
            {
                var viewModel = new EmployeesViewModel
                {
                    Employees = employeeService.GetAll()
                };

                return(PartialView("_Index", viewModel));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 10
0
        public ActionResult Create()
        {
            EmployeesCodesBLL  AuthorizedPersonBLL = new EmployeesCodesBLL().GetEVacationAuthorizedPersonOfEmployee(WindowsUserIdentity, EServicesTypesEnum.Vacation);
            EmployeesViewModel AuthorizedPerson    = AuthorizedPersonBLL != null ? new EmployeesViewModel()
            {
                EmployeeCodeNo = AuthorizedPersonBLL?.EmployeeCodeNo, EmployeeNameAr = AuthorizedPersonBLL?.Employee?.EmployeeNameAr
            } : null;
            VacationsViewModel VacationVM = new VacationsViewModel()
            {
                VacationType              = new VacationsTypesBLL(),
                EmployeeCodeNo            = WindowsUserIdentity,
                EVacationAuthorizedPerson = AuthorizedPerson
            };

            return(View(VacationVM));
        }
        private string UploadedFile(EmployeesViewModel model)
        {
            string uniqueFileName = null;

            if (model.ProfileImage != null)
            {
                string uploadsFolder = Path.Combine(_webHostEnvironment.WebRootPath, "images");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + model.ProfileImage.FileName;
                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.ProfileImage.CopyTo(fileStream);
                }
            }
            return(uniqueFileName);
        }
Exemplo n.º 12
0
        // GET: Employees
        public ActionResult Index()
        {
            List <EmployeesViewModel> model = new List <EmployeesViewModel>();

            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            try
            {
                List <Employees> employees = entities.Employees.OrderBy(Employees => Employees.LastName).ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (Employees employee in employees)
                {
                    EmployeesViewModel view = new EmployeesViewModel();
                    view.Id_Employee       = employee.Id_Employee;
                    view.FirstName         = employee.FirstName;
                    view.LastName          = employee.LastName;
                    view.PhoneNumber       = employee.PhoneNumber;
                    view.EmailAddress      = employee.EmailAddress;
                    view.EmployeeReference = employee.EmployeeReference;
                    view.DeletedAt         = employee.DeletedAt;
                    view.Active            = employee.Active;
                    view.EmployeePicture   = employee.EmployeePicture;

                    view.Id_PinCode = employee.PinCodes.FirstOrDefault()?.Id_PinCode;
                    view.PinCode    = employee.PinCodes.FirstOrDefault()?.PinCode;
                    ViewBag.PinCode = new SelectList((from u in db.PinCodes select new { Id_PinCode = u.Id_PinCode, PinCode = u.PinCode }), "Id_PinCode", "PinCode", null);


                    view.Id_Contractor = employee.Contractors?.Id_Contractor;
                    view.CompanyName   = employee.Contractors?.CompanyName;

                    view.Id_Department  = employee.Departments?.Id_Department;
                    view.DepartmentName = employee.Departments?.DepartmentName;

                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }



            return(View(model));
        }//Index
Exemplo n.º 13
0
        // GET: Employees
        public ActionResult Index()
        {
            var employees   = db.Users.Where(x => x.Email != "*****@*****.**").ToList();
            var roles       = db.CompanyRoles.ToList();
            var currentUser = User.Identity.GetUserId();

            var userHasFocuses = db.EmployeeHasFocuses.Where(x => x.User.Id == currentUser).ToList();

            var viewModel = new EmployeesViewModel();

            viewModel.Focuses = userHasFocuses;
            viewModel.Roles   = roles;
            viewModel.Users   = employees;


            return(View(viewModel));
        }
Exemplo n.º 14
0
 private string ProcessingFileUploadMethod(EmployeesViewModel obj, string uniqueFile)
 {
     if (obj.imagePath != null && obj.imagePath.Count > 0)
     {
         foreach (IFormFile item in obj.imagePath)
         {
             string UploadsFolders = Path.Combine(_hostingEnvironment.WebRootPath, "images");
             uniqueFile = Guid.NewGuid().ToString() + "_" + item.FileName;
             string FilePath = Path.Combine(UploadsFolders, uniqueFile);
             using (var fileStream = new FileStream(FilePath, FileMode.Create))
             {
                 item.CopyTo(fileStream);
             }
         }
     }
     return(uniqueFile);
 }
Exemplo n.º 15
0
        public async Task <IActionResult> Register(EmployeesViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _employeesManage.Register(model.TheWorkNumber, model.Password, model.Name, model.Sex, model.Age,
                                                model.Phone, model.Email, model.Address, model.Image, model.Remarks, model.Status, model.BranchId);

                return(Ok(new EndState()
                {
                    Code = 200, IsSucceed = true, ErrorMessage = "注册成功"
                }));
            }
            return(Ok(new EndState()
            {
                Code = 500, IsSucceed = false, ErrorMessage = "数据模型验证失败"
            }));
        }
        public EmployeesPage()
        {
            InitializeComponent();

            BindingContext = new EmployeesViewModel();

            if (Device.OS == TargetPlatform.Windows)
            {
                var toolbarItem = new ToolbarItem
                {
                    Icon    = "refresh.png",
                    Command = ViewModel.RefreshCommand
                };

                ToolbarItems.Add(toolbarItem);
            }
        }
Exemplo n.º 17
0
        public ActionResult Edit(EmployeesViewModel model)
        {
            Employees view = db.Employees.Find(model.EmployeeID);

            view.LastName        = model.LastName;
            view.FirstName       = model.FirstName;
            view.Title           = model.Title;
            view.TitleOfCourtesy = model.TitleOfCourtesy;
            view.BirthDate       = model.BirthDate;
            view.HireDate        = model.HireDate;
            view.Address         = model.Address;
            view.City            = model.City;
            view.Region          = model.Region;
            view.PostalCode      = model.PostalCode;
            view.Country         = model.Country;
            view.HomePhone       = model.HomePhone;
            view.Extension       = model.Extension;
            //view.Photo = model.Photo;
            view.Notes     = model.Notes;
            view.ReportsTo = model.ReportsTo;
            //view.PhotoPath = model.PhotoPath;

            //if (cus.PinCodes == null)
            //{
            //    PinCodes pic = new PinCodes();
            //    pic.PinCode = model.PinCode;
            //    //usr.Password = "******";
            //    pic.Customers = cus;

            //    db.PinCodes.Add(pic);
            //}
            //else
            //{
            //    PinCodes pic = cus.PinCodes.FirstOrDefault();
            //    if (pic != null)
            //    {
            //        pic.PinCode = model.PinCode;
            //    }
            //}

            ViewBag.ReportsTo = new SelectList((from e in db.Employees select new { EmployeeID = e.EmployeeID, ReportsTo = e.ReportsTo }), "EmployeeID", "ReportsTo", null);

            db.SaveChanges();
            return(View("Index"));
        }//edit
Exemplo n.º 18
0
        // GET: Employees
        public ActionResult Index()
        {
            List <EmployeesViewModel> model = new List <EmployeesViewModel>();

            NorthwindDataEntities entities = new NorthwindDataEntities();

            try
            {
                List <Employees> employees = entities.Employees.OrderBy(Employees => Employees.LastName).ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (Employees employee in employees)
                {
                    EmployeesViewModel view = new EmployeesViewModel();
                    view.EmployeeID      = employee.EmployeeID;
                    view.LastName        = employee.LastName;
                    view.FirstName       = employee.FirstName;
                    view.Title           = employee.Title;
                    view.TitleOfCourtesy = employee.TitleOfCourtesy;
                    view.BirthDate       = employee.BirthDate;
                    view.HireDate        = employee.HireDate;
                    view.Address         = employee.Address;
                    view.City            = employee.City;
                    view.Region          = employee.Region;
                    view.PostalCode      = employee.PostalCode;
                    view.Country         = employee.Country;
                    view.HomePhone       = employee.HomePhone;
                    view.Extension       = employee.Extension;
                    //view.Photo = employee.Photo;
                    view.Notes     = employee.Notes;
                    view.ReportsTo = employee.ReportsTo;
                    //view.PhotoPath = employee.PhotoPath;

                    ViewBag.ReportsTo = new SelectList((from e in db.Employees select new { EmployeeID = e.EmployeeID, ReportsTo = e.ReportsTo }), "EmployeeID", "ReportsTo", null);

                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }

            return(View(model));
        }//Index
Exemplo n.º 19
0
        // GET: Employees/Details/5
        public ActionResult Details(int?id)
        {
            EmployeesViewModel model = new EmployeesViewModel();

            NorthwindDataEntities entities = new NorthwindDataEntities();

            try
            {
                Employees employee = entities.Employees.Find(id);
                if (employee == null)
                {
                    return(HttpNotFound());
                }

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                EmployeesViewModel view = new EmployeesViewModel();
                view.EmployeeID      = employee.EmployeeID;
                view.LastName        = employee.LastName;
                view.FirstName       = employee.FirstName;
                view.Title           = employee.Title;
                view.TitleOfCourtesy = employee.TitleOfCourtesy;
                view.BirthDate       = employee.BirthDate;
                view.HireDate        = employee.HireDate;
                view.Address         = employee.Address;
                view.City            = employee.City;
                view.Region          = employee.Region;
                view.PostalCode      = employee.PostalCode;
                view.Country         = employee.Country;
                view.HomePhone       = employee.HomePhone;
                view.Extension       = employee.Extension;
                view.Photo           = employee.Photo;
                view.Notes           = employee.Notes;
                view.ReportsTo       = employee.ReportsTo;
                view.PhotoPath       = employee.PhotoPath;

                ViewBag.ReportsTo = new SelectList((from e in db.Employees select new { EmployeeID = e.EmployeeID, ReportsTo = e.ReportsTo }), "EmployeeID", "ReportsTo", null);

                model = view;
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }//details
Exemplo n.º 20
0
        //[CustomAuthorizeAttribute(AllowedRole = "Admin, Manager, User")]
        public ActionResult GetEmployeesByCriteria(EmployeeSearchCriteriaViewModel criteria)
        {
            var searchCriteriaModel = new EmployeeSearchCriteriaModel();

            Mapper.Map(criteria, searchCriteriaModel);

            var employeeList = _employeeService.GetEmployeesByCriteria(searchCriteriaModel);

            var employeeListViewModel = new List <EmployeesListViewModel>();

            Mapper.Map(employeeList, employeeListViewModel);

            var employees = new EmployeesViewModel {
                Employees = employeeListViewModel, SearchCriteria = new EmployeeSearchCriteriaViewModel()
            };

            return(View("GetAllEmployeesList", employees));
        }
Exemplo n.º 21
0
        public ActionResult Employees(EmployeesViewModel model, string returnUrl)
        {
            //var employees =
            //    Northwind.Employees.Where(
            //        e => e.FirstName.Contains(model.EmployeeName) || e.LastName.Contains(model.EmployeeName)).ToList();

            var employees =
                Northwind.Employees.SqlQuery("Select * from dbo.employees where FirstName like '%" + model.EmployeeName +
                                             "%'").ToList();

            // ' or 1 = 1--
            // ' UPDATE dbo.employees set PlainTextPassword = '******' --


            model.Employees = employees;

            return(View("Index", model));
        }
Exemplo n.º 22
0
        public ActionResult Edit(EmployeesViewModel model)
        {
            Employees emp = new Employees();

            emp.FirstName         = model.FirstName;
            emp.LastName          = model.LastName;
            emp.PhoneNumber       = model.PhoneNumber;
            emp.EmailAddress      = model.EmailAddress;
            emp.EmployeeReference = model.EmployeeReference;
            emp.DeletedAt         = model.DeletedAt;
            emp.Active            = model.Active;
            emp.EmployeePicture   = model.EmployeePicture;

            int contractorId = int.Parse(model.CompanyName);

            if (contractorId > 0)
            {
                Contractors con = db.Contractors.Find(contractorId);
                emp.Id_Contractor = con.Id_Contractor;
            }

            int departmentId = int.Parse(model.DepartmentName);

            if (departmentId > 0)
            {
                Departments dep = db.Departments.Find(departmentId);
                emp.Id_Department = dep.Id_Department;
            }

            ViewBag.DepartmentName = new SelectList((from d in db.Departments select new { Id_Department = d.Id_Department, DepartmentName = d.DepartmentName }), "Id_Department", "DepartmentName", null);

            ViewBag.CompanyName = new SelectList((from c in db.Contractors select new { Id_Contractor = c.Id_Contractor, CompanyName = c.CompanyName }), "Id_Contractor", "CompanyName", null);

            try
            {
                db.SaveChanges();
            }

            catch (Exception ex)
            {
            }

            return(View("Index"));
        }//edit
Exemplo n.º 23
0
        public ActionResult Create(EmployeesViewModel EmployeeVM)
        {
            EmployeesBLL _employeeBll = new EmployeesBLL()
            {
                EmployeeIDNo              = EmployeeVM.EmployeeIDNo,
                FirstNameAr               = EmployeeVM.FirstNameAr,
                MiddleNameAr              = EmployeeVM.MiddleNameAr,
                GrandFatherNameAr         = EmployeeVM.GrandFatherNameAr,
                LastNameAr                = EmployeeVM.LastNameAr,
                FirstNameEn               = EmployeeVM.FirstNameEn,
                MiddleNameEn              = EmployeeVM.MiddleNameEn,
                GrandFatherNameEn         = EmployeeVM.GrandFatherNameEn,
                LastNameEn                = EmployeeVM.LastNameEn,
                EmployeeBirthDate         = EmployeeVM.EmployeeBirthDate,
                EmployeeBirthPlace        = EmployeeVM.EmployeeBirthPlace,
                EmployeeMobileNo          = EmployeeVM.EmployeeMobileNo,
                EmployeePassportNo        = EmployeeVM.EmployeePassportNo,
                EmployeeEMail             = EmployeeVM.EmployeeEMail,
                EmployeeIDIssueDate       = EmployeeVM.EmployeeIDIssueDate,
                EmployeePassportSource    = EmployeeVM.EmployeePassportSource,
                EmployeePassportIssueDate = EmployeeVM.EmployeePassportIssueDate,
                EmployeePassportEndDate   = EmployeeVM.EmployeePassportEndDate,
                EmployeeIDExpiryDate      = EmployeeVM.EmployeeIDExpiryDate,
                EmployeeIDCopyNo          = EmployeeVM.EmployeeIDCopyNo,
                EmployeeIDIssuePlace      = EmployeeVM.EmployeeIDIssuePlace,
                DependentCount            = EmployeeVM.DependentCount,
                MaritalStatus             = new MaritalStatusBLL()
                {
                    MaritalStatusID = EmployeeVM.MaritalStatus.MaritalStatusID
                },
                Gender = new GendersBLL()
                {
                    GenderID = EmployeeVM.GenderID
                },
                Nationality = new CountriesBLL {
                    CountryID = EmployeeVM.CountryID
                },
                LoginIdentity = UserIdentity
            };

            _employeeBll.Add();
            return(View(EmployeeVM));
        }
Exemplo n.º 24
0
        public bool AddUpdateEmployee(EmployeesViewModel Emp)
        {
            Employees employee = new Employees
            {
                EmployeeId      = Emp.EmployeeId,
                Address         = Emp.Address,
                CreatedBy       = SessionManagement.LoggedInUser.UserId,
                CreatedDate     = DateTime.Now,
                FirstName       = Emp.FirstName,
                HireDate        = Emp.HireDate,
                TerminationDate = Emp.TerminationDate != DateTime.MinValue ? Emp.TerminationDate : DateTime.Now,
                IsActive        = true,
                IsDeleted       = false,
                Lastname        = Emp.Lastname,
                Title           = Emp.Title
            };

            return(this._IEmployeeRepository.AddUpdateEmployee(employee, Emp.ClientId));
        }
Exemplo n.º 25
0
        public async Task <IActionResult> Index([FromQuery] string search = "", [FromQuery] int page = 1, [FromQuery] int totalLoadedItems = 0)
        {
            EmployeesViewModel viewModel = new EmployeesViewModel();

            if (page < 1)
            {
                mLogger.LogInformation($"<strong>page</strong> parameter cannot be less than 1.");
                viewModel.HasError = true;
                viewModel.Message  = $"* page parameter cannot be less than 1.";
                return(View(viewModel));
            }

            if (!await mContext.Employees.AnyAsync())
            {
                mLogger.LogInformation("There are no items in the Database");
                viewModel.HasError = true;
                viewModel.Message  = "There are no items to show. Try loading them from *.csv file.";
                return(View(viewModel));
            }

            var employeeDtos = await mContext.Employees
                               .Where(e => string.IsNullOrWhiteSpace(search) || EmployeeMatchesSearch(e, search))
                               .Skip((page - 1) * ITEMS_PER_PAGE)
                               .Take(ITEMS_PER_PAGE)
                               .Select(e => e.ToEmployeeDto())
                               .ToListAsync();

            int totalItems = await mContext.Employees.CountAsync();

            int totalPages = (int)Math.Ceiling((double)totalItems / ITEMS_PER_PAGE);

            viewModel.Employees   = employeeDtos;
            viewModel.TotalPages  = totalPages;
            viewModel.CurrentPage = page;

            if (totalLoadedItems > 0)
            {
                viewModel.Message = $"You have successfully loaded {totalLoadedItems} employees.";
            }

            return(View(viewModel));
        }
Exemplo n.º 26
0
        public IActionResult Employees()
        {
            var model = new EmployeesViewModel
            {
                Employees = new List <Employee>
                {
                    new Employee {
                        Name     = "Tahir Naushad",
                        JobTitle = "Software Developer",
                        Profile  = "C#/ASP.NET Developer",
                        Friends  = new List <Friend>
                        {
                            new Friend {
                                Name = "Tom"
                            },
                            new Friend {
                                Name = "Dick"
                            },
                            new Friend {
                                Name = "Harry"
                            },
                        }
                    },
                    new Employee {
                        Name     = "James Bond",
                        JobTitle = "MI6 Agent",
                        Profile  = "Has licence to kill",
                        Friends  = new List <Friend>
                        {
                            new Friend {
                                Name = "James Gordon"
                            },
                            new Friend {
                                Name = "Robin Hood"
                            },
                        }
                    },
                }
            };

            return(View(model));
        }
Exemplo n.º 27
0
		public HRViewModel(SKDTabItems skdTabItems)
		{
			SKDTabItems = skdTabItems;
			EditFilterCommand = new RelayCommand(OnEditFilter, CanEditFilter);
			ChangeIsDeletedCommand = new RelayCommand(OnChangeIsDeleted, CanChangeIsDeleted);
			EmployeesViewModel = new EmployeesViewModel();
			DepartmentsViewModel = new DepartmentsViewModel();
			PositionsViewModel = new PositionsViewModel();
			AdditionalColumnTypesViewModel = new AdditionalColumnTypesViewModel();
			CardsViewModel = new CardsViewModel();
			AccessTemplatesViewModel = new AccessTemplatesViewModel();
			PassCardTemplatesViewModel = new PassCardTemplatesViewModel();
			OrganisationsViewModel = new OrganisationsViewModel();
			DepartmentFilter = new DepartmentFilter();
			PositionFilter = new PositionFilter();
			CardFilter = new CardFilter();
			if (CanSelectEmployees) 
				IsEmployeesSelected = true;
			else if (CanSelectDepartments) 
				IsDepartmentsSelected = true;
			else if (CanSelectPositions) 
				IsPositionsSelected = true;
			else if (CanSelectAdditionalColumns) 
				IsAdditionalColumnTypesSelected = true;
			else if (CanSelectCards) 
				IsCardsSelected = true;
			else if (CanSelectAccessTemplates) 
				IsAccessTemplatesSelected = true;
			else if (CanSelectPassCardTemplates) 
				IsPassCardTemplatesSelected = true;
			else if (CanSelectOrganisations) 
				IsOrganisationsSelected = true;
			PersonTypes = new ObservableCollection<PersonType>();
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Employees_View))
				PersonTypes.Add(PersonType.Employee);
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Guests_View))
				PersonTypes.Add(PersonType.Guest);
			_selectedPersonType = PersonTypes.FirstOrDefault();
			var user = ClientManager.CurrentUser;
			Filter = new HRFilter() { User = user };
			Filter.EmployeeFilter.User = user;
		}
        // GET: Employees
        public IActionResult Index()
        {
            IEnumerable <EmployeesViewModel> list = null;

            try
            {
                list = EmployeesViewModel.ConvertModelToVM(_context.Employees.ToList(), _context);
                if (list == null)
                {
                    return(NotFound());
                }
            }
            catch (Exception)
            {
                list = Enumerable.Empty <EmployeesViewModel>();

                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
            }
            return(View(list));
        }
Exemplo n.º 29
0
        public ActionResult TakeRole(int id, EmployeesViewModel newFocus)
        {
            var currentUser = User.Identity.GetUserId();
            List <EmployeeHasFocus> currentUserHasFocuses = db.EmployeeHasFocuses.Where(x => x.UserId == currentUser).ToList();



            if (currentUserHasFocuses.Count < 3)
            {
                db.EmployeeHasFocuses.Add(new EmployeeHasFocus()
                {
                    RoleId = id, UserId = currentUser, YearlyFocus = DateTime.Now.AddYears(1)
                });
                db.SaveChanges();
            }



            return(RedirectToAction("Index"));
        }
Exemplo n.º 30
0
        }//Index

        // GET: Employees/Details/5
        public ActionResult Details(int?id)
        {
            EmployeesViewModel model = new EmployeesViewModel();

            MobileWorkDataEntities entities = new MobileWorkDataEntities();

            try
            {
                Employees employeedetail = entities.Employees.Find(id);
                if (employeedetail == null)
                {
                    return(HttpNotFound());
                }

                // muodostetaan näkymämalli tietokannan rivien pohjalta

                EmployeesViewModel view = new EmployeesViewModel();
                view.Id_Employee       = employeedetail.Id_Employee;
                view.FirstName         = employeedetail.FirstName;
                view.LastName          = employeedetail.LastName;
                view.PhoneNumber       = employeedetail.PhoneNumber;
                view.EmailAddress      = employeedetail.EmailAddress;
                view.EmployeeReference = employeedetail.EmployeeReference;
                view.DeletedAt         = employeedetail.DeletedAt;
                view.Active            = employeedetail.Active;
                view.EmployeePicture   = employeedetail.EmployeePicture;

                view.Id_Contractor = employeedetail.Contractors?.Id_Contractor;
                view.CompanyName   = employeedetail.Contractors?.CompanyName;

                view.Id_Department  = employeedetail.Departments?.Id_Department;
                view.DepartmentName = employeedetail.Departments?.DepartmentName;

                model = view;
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }//details
        public static Employee MapViewToEmployee(EmployeesViewModel employeesViewModel)
        {
            Employee employee = new Employee
            {
                ID          = employeesViewModel.ID,
                FirstName   = employeesViewModel.FirstName,
                LastName    = employeesViewModel.LastName,
                Email       = employeesViewModel.Email,
                PhoneNumber = employeesViewModel.PhoneNumber,
                Position    = employeesViewModel.Position,
                Salary      = employeesViewModel.Salary,
                Street      = employeesViewModel.Street,
                Town        = employeesViewModel.Town,
                PostalCode  = employeesViewModel.PostalCode,
                Voivodeship = employeesViewModel.Voivodeship,
                Country     = employeesViewModel.Country,
                ownerID     = employeesViewModel.ownerID
            };

            return(employee);
        }
        public ActionResult Index(EmployeesViewModel instance)
        {
            NorthwindEntities db = new NorthwindEntities();

            //var pred = PredicateBuilder.New<Employees>(true);

            //if (instance.SearchList != null)
            //{
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.LastName))
            //    {
            //        pred = pred.And(p => p.LastName.Contains(instance.SearchList.LastName.Trim()));
            //    }
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.FirstName))
            //    {
            //        pred = pred.And(p => p.FirstName.Contains(instance.SearchList.FirstName.Trim()));
            //    }
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.Title))
            //    {
            //        pred = pred.And(p => p.Title.Contains(instance.SearchList.Title.Trim()));
            //    }
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.Address))
            //    {
            //        pred = pred.And(p => p.Address.Contains(instance.SearchList.Address.Trim()));
            //    }
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.City))
            //    {
            //        pred = pred.And(p => p.City.Contains(instance.SearchList.City.Trim()));
            //    }
            //    if (!string.IsNullOrWhiteSpace(instance.SearchList.Notes))
            //    {
            //        pred = pred.And(p => p.Notes.Contains(instance.SearchList.Notes.Trim()));
            //    }
            //}

            var pred = LinqkitHelper.GetPredicate <Employees, EmployeesSearchModel>(instance.SearchList);

            instance.EmployeesDataList = db.Employees.Where(pred);

            return(View(instance));
        }
Exemplo n.º 33
0
		public void AdditionalColumns()
		{
			var organisation1 = new Organisation();
			var organisation2 = new Organisation();
			var employee1 = new ShortEmployee { OrganisationUID = organisation1.UID };
			var employee2 = new ShortEmployee { OrganisationUID = organisation2.UID };
			var additionalColumnType1 = new AdditionalColumnType { OrganisationUID = organisation1.UID, IsInGrid = true, DataType = AdditionalColumnDataType.Text };
			var additionalColumnType2 = new AdditionalColumnType { OrganisationUID = organisation1.UID, IsInGrid = true, DataType = AdditionalColumnDataType.Text };
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns<OrganisationFilter>(filter =>
				{
					var result = new List<Organisation>();
					if (filter.UIDs.Count == 0)
					{
						result.Add(organisation1);
						result.Add(organisation2);
					}
					if (filter.UIDs.Any(x => x == organisation1.UID))
						result.Add(organisation1);
					if (filter.UIDs.Any(x => x == organisation2.UID))
						result.Add(organisation2);
					return new OperationResult<List<Organisation>>(result);
				});
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns<EmployeeFilter>(filter =>
				{
					var result = new List<ShortEmployee>();
					if(filter.OrganisationUIDs.Count == 0)
					{
						result.Add(employee1);
						result.Add(employee2);
					}
					if (filter.OrganisationUIDs.Any(x => x == organisation1.UID))
						result.Add(employee1);
					if (filter.OrganisationUIDs.Any(x => x == organisation2.UID))
						result.Add(employee2);
					return new OperationResult<List<ShortEmployee>>(result);
				});
			mock.Setup(x => x.GetAdditionalColumnTypes(It.IsAny<AdditionalColumnTypeFilter>())).Returns<AdditionalColumnTypeFilter>(filter =>
			{
				var result = new List<AdditionalColumnType>();
				if (filter.OrganisationUIDs.Count == 0)
				{
					result.Add(additionalColumnType1);
					result.Add(additionalColumnType2);
				}
				if (filter.OrganisationUIDs.Any(x => x == organisation1.UID))
					result.Add(additionalColumnType1);
				if (filter.OrganisationUIDs.Any(x => x == organisation2.UID))
					result.Add(additionalColumnType2);
				return new OperationResult<List<AdditionalColumnType>>(result);
			});
			ClientManager.RubezhService = mock.Object;

			var employeesViewModel = new EmployeesViewModel();
			employeesViewModel.Initialize(new EmployeeFilter());
			Assert.IsTrue(employeesViewModel.AdditionalColumnTypes.Count == 2);
			employeesViewModel.Initialize(new EmployeeFilter { OrganisationUIDs = new List<Guid> { organisation1.UID } });
			Assert.IsTrue(employeesViewModel.AdditionalColumnTypes.Count == 1);
		}
Exemplo n.º 34
0
		public void IsShowDeletedPosition()
		{
			var organisation = new Organisation();
			var department = new ShortDepartment { Name = "DeletedDepartment", OrganisationUID = organisation.UID, IsDeleted = true };
			var position = new ShortPosition { Name = "DeletedPosition", OrganisationUID = organisation.UID, IsDeleted = true };
			var employee = new Employee 
			{
				FirstName = "FName",
				SecondName = "SName",
				LastName = "LName",
				OrganisationUID = organisation.UID, 
				DepartmentName = department.Name, 
				DepartmentUID = department.UID, 
				IsDepartmentDeleted = department.IsDeleted,
				PositionName = position.Name,
				PositionUID = position.UID,
				IsPositionDeleted = position.IsDeleted
			};
			var shortEmployee = new ShortEmployee
			{
				UID = employee.UID,
				FirstName = employee.FirstName,
				SecondName = employee.SecondName,
				LastName = employee.LastName,
				OrganisationUID = organisation.UID,
				DepartmentName = department.Name,
				IsDepartmentDeleted = department.IsDeleted,
				PositionName = position.Name,
				IsPositionDeleted = position.IsDeleted
			};
			ClientManager.CurrentUser.PermissionStrings.Add("Oper_SKD_Employees_Edit");
			var mock = new Mock<ISafeRubezhService>();
			mock.Setup(x => x.GetOrganisations(It.IsAny<OrganisationFilter>())).Returns(() =>
			{
				return new OperationResult<List<Organisation>>(new List<Organisation> { organisation });
			});
			mock.Setup(x => x.GetEmployeeList(It.IsAny<EmployeeFilter>())).Returns(() =>
			{
				return new OperationResult<List<ShortEmployee>>(new List<ShortEmployee> { shortEmployee});
			});
			mock.Setup(x => x.GetEmployeeDetails(It.IsAny<Guid>())).Returns(() =>
			{
				return new OperationResult<Employee>(employee);
			});
			mock.Setup(x => x.GetAdditionalColumnTypes(It.IsAny<AdditionalColumnTypeFilter>())).Returns(() =>
			{
				return new OperationResult<List<AdditionalColumnType>>();
			});
			mock.Setup(x => x.SaveEmployee(It.IsAny<Employee>(), It.IsAny<bool>())).Returns(() =>
			{
				return new OperationResult<bool>(true);
			});
			ClientManager.RubezhService = mock.Object;
			(ServiceFactory.DialogService as MockDialogService).OnShowModal += window => (window as EmployeeDetailsViewModel).SaveCommand.Execute();

			var employeesViewModel = new EmployeesViewModel();
			employeesViewModel.Initialize(new EmployeeFilter());
			employeesViewModel.SelectedItem = employeesViewModel.Organisations.FirstOrDefault().Children.FirstOrDefault();
			employeesViewModel.EditCommand.Execute();
			Assert.IsTrue(employeesViewModel.SelectedItem.DepartmentName == null || employeesViewModel.SelectedItem.DepartmentName == "");
			Assert.IsTrue(employeesViewModel.SelectedItem.PositionName == null || employeesViewModel.SelectedItem.PositionName == "");
		}
Exemplo n.º 35
0
        public JsonResult GetEmployeesFilter(bool isWithDeleted, PersonType selectedPersonType)
        {
            var employeeFilter = new EmployeeFilter
            {
                LogicalDeletationType = isWithDeleted ? LogicalDeletationType.All : LogicalDeletationType.Active,
                PersonType = selectedPersonType
            };

            var employeesViewModel = new EmployeesViewModel();
            employeesViewModel.Initialize(employeeFilter);

            dynamic result = new
            {
                page = 1,
                total = 100,
                records = 100,
                rows = employeesViewModel.Organisations,
            };

            return Json(result, JsonRequestBehavior.AllowGet);
        }