示例#1
0
        public override void Execute(object parameter)
        {
            List <Employee>      employees      = DB.EmployeeRepository.Get();
            List <EmployeeModel> employeeModels = new List <EmployeeModel>();
            EmployeeMapper       employeeMapper = new EmployeeMapper();


            for (int i = 0; i < employees.Count; i++)
            {
                Employee employee = employees[i];

                EmployeeModel employeeModel = employeeMapper.Map(employee);
                employeeModel.No = i + 1;

                employeeModels.Add(employeeModel);
            }

            Enumeration.Enumerate(employeeModels);

            EmployeeViewModel employeeViewModel = new EmployeeViewModel();

            employeeViewModel.AllEmployees = employeeModels;
            employeeViewModel.Employees    = new ObservableCollection <EmployeeModel>(employeeModels);

            EmployeesControl employeesControl = new EmployeesControl();

            employeesControl.DataContext = employeeViewModel;

            MainWindow mainWindow = (MainWindow)mainViewModel.Window;

            mainWindow.GrdCenter.Children.Clear();
            mainWindow.GrdCenter.Children.Add(employeesControl);
        }
示例#2
0
        public JsonResult EditEmployee([FromBody] EmployeeViewModel vm)
        {
            var map = EmployeeMapper.Convert(vm);
            var id  = _employeeService.UpdateEmployee(map);

            return(Json(new { data = id }));
        }
        public async Task <IActionResult> GetAllEmployees(int?id)
        {
            if (id == null)
            {
                return(IdNotProvidedBadRequest(logger.Here()));
            }
            Department department = await departmentService.FindDepartmentAsync(id);

            if (department == null)
            {
                return(ModelNotFound(logger.Here(), id));
            }

            var employees = await employeeService.GetEmployeesForDepartment(department.DepartmentId)
                            .Include(emp => emp.Department)
                            .Include(emp => emp.Position)
                            .AsNoTracking()
                            .Take(10)
                            .ToListAsync();

            logger.Here().Information($"Get employees for department: '{department.Name}' successfully");
            //map to response
            EmployeeGetAllResponse employeeGetAllResponse = EmployeeMapper.MapFromEmployeesToEmployeeGetAllResponse(employees);

            return(Ok(employeeGetAllResponse));
        }
 public EmployeeController(IEmployeeRepository employeeRepository)
 {
     this.employeeRepository = new DataAccessLayerEF.Repositories.EmployeeRepository();
     this.branchRepository   = new DataAccessLayerEF.Repositories.BranchRepository();
     this.positionRepository = new DataAccessLayerEF.Repositories.PositionRepository();
     employeeMapper          = new EmployeeMapper();
 }
示例#5
0
        public JsonResult AddEmployee([FromBody] EmployeeViewModel vm)
        {
            var map      = EmployeeMapper.Convert(vm);
            var response = _bCSDirectoryService.AddEmployee(map);

            return(Json(new { data = response }));
        }
示例#6
0
        public void TestMappingForCustomDateEntity()
        {
            var mapper     = new EmployeeMapper();
            var mappedData = mapper.MapCustomDate(_employees);

            Assert.NotNull(mappedData);
            Assert.AreEqual(4, mappedData.Count);
            Assert.AreEqual("PersonNumber", mappedData[0].Person.PersonNumber);
            Assert.AreEqual(new DateTime(2017, 1, 15), mappedData[0].Date);
            Assert.AreEqual("CustomDateTypeName1", mappedData[0].CustomDateTypeName);
            Assert.AreEqual("FirstName", mappedData[0].Person.FirstName);
            Assert.AreEqual("LastName", mappedData[0].Person.LastName);

            Assert.AreEqual("PersonNumber", mappedData[1].Person.PersonNumber);
            Assert.AreEqual(new DateTime(2017, 1, 16), mappedData[1].Date);
            Assert.AreEqual("CustomDateTypeName1_2", mappedData[1].CustomDateTypeName);
            Assert.AreEqual("FirstName", mappedData[1].Person.FirstName);
            Assert.AreEqual("LastName", mappedData[1].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[2].Person.PersonNumber);
            Assert.AreEqual(new DateTime(2017, 1, 17), mappedData[2].Date);
            Assert.AreEqual("CustomDateTypeName2", mappedData[2].CustomDateTypeName);
            Assert.AreEqual("FirstName2", mappedData[2].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[2].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[3].Person.PersonNumber);
            Assert.AreEqual(new DateTime(2017, 1, 18), mappedData[3].Date);
            Assert.AreEqual("CustomDateTypeName2_2", mappedData[3].CustomDateTypeName);
            Assert.AreEqual("FirstName2", mappedData[3].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[3].Person.LastName);
        }
示例#7
0
        public void TestMappingForPayRuleEntityIsInputIsEmpty()
        {
            var mapper     = new EmployeeMapper();
            var mappedData = mapper.MapPayRule(null);

            Assert.NotNull(mappedData);
        }
示例#8
0
        public void TestMappingForCustomFieldEntityIsInputIsEmpty()
        {
            var mapper     = new EmployeeMapper();
            var mappedData = mapper.MapCustomField(null);

            Assert.NotNull(mappedData);
        }
示例#9
0
        public void TestMappingForCustomFieldEntity()
        {
            var mapper     = new EmployeeMapper();
            var mappedData = mapper.MapCustomField(_employees);

            Assert.NotNull(mappedData);
            Assert.AreEqual(4, mappedData.Count);
            Assert.AreEqual("PersonNumber", mappedData[0].Person.PersonNumber);
            Assert.AreEqual("Text1", mappedData[0].Text);
            Assert.AreEqual("CustomDataTypeName1", mappedData[0].CustomDataTypeName);
            Assert.AreEqual("FirstName", mappedData[0].Person.FirstName);
            Assert.AreEqual("LastName", mappedData[0].Person.LastName);

            Assert.AreEqual("PersonNumber", mappedData[1].Person.PersonNumber);
            Assert.AreEqual("Text1_2", mappedData[1].Text);
            Assert.AreEqual("CustomDataTypeName1_2", mappedData[1].CustomDataTypeName);
            Assert.AreEqual("FirstName", mappedData[1].Person.FirstName);
            Assert.AreEqual("LastName", mappedData[1].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[2].Person.PersonNumber);
            Assert.AreEqual("Text2", mappedData[2].Text);
            Assert.AreEqual("CustomDataTypeName2", mappedData[2].CustomDataTypeName);
            Assert.AreEqual("FirstName2", mappedData[2].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[2].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[3].Person.PersonNumber);
            Assert.AreEqual("Text2_2", mappedData[3].Text);
            Assert.AreEqual("CustomDataTypeName2_2", mappedData[3].CustomDataTypeName);
            Assert.AreEqual("FirstName2", mappedData[3].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[3].Person.LastName);
        }
示例#10
0
        public void TestMappingForEmployeeLicenseEntity()
        {
            var mapper     = new EmployeeMapper();
            var mappedData = mapper.MapLicense(_employees);

            Assert.NotNull(mappedData);
            Assert.AreEqual(3, mappedData.Count);
            Assert.AreEqual("PersonNumber", mappedData[0].Person.PersonNumber);
            Assert.AreEqual(true, mappedData[0].ActiveFlag);
            Assert.AreEqual("LicenseTypeName", mappedData[0].LicenseTypeName);
            Assert.AreEqual("FirstName", mappedData[0].Person.FirstName);
            Assert.AreEqual("LastName", mappedData[0].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[1].Person.PersonNumber);
            Assert.AreEqual(false, mappedData[1].ActiveFlag);
            Assert.AreEqual("LicenseTypeName2", mappedData[1].LicenseTypeName);
            Assert.AreEqual("FirstName2", mappedData[1].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[1].Person.LastName);

            Assert.AreEqual("PersonNumber2", mappedData[2].Person.PersonNumber);
            Assert.AreEqual(true, mappedData[2].ActiveFlag);
            Assert.AreEqual("LicenseTypeName2_2", mappedData[2].LicenseTypeName);
            Assert.AreEqual("FirstName2", mappedData[2].Person.FirstName);
            Assert.AreEqual("LastName2", mappedData[2].Person.LastName);
        }
示例#11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["EmployeeId"] == null || Request.QueryString["ContractTemplateId"] == null)
            {
                Response.Redirect("List.aspx");
            }
            if (!IsPostBack)
            {
                ContractTemplateEntity ctemplate = new ContractTemplateMapper()
                                                   .Get(Convert.ToInt32(Request.QueryString["ContractTemplateId"]));

                ContractTypeHeaderText.Text          = "(" + ctemplate.Title + " Contract)";
                ContractTemplateTitleLabel.InnerText = ctemplate.Title;

                string s = DateTime.Now.ToString("dd.MM.yyyy");
                s = s.Replace(".", "");

                EmployeeView employeeView = new EmployeeView();
                employeeView = new EmployeeMapper().Get(new EmployeeEntity()
                {
                    Id = Convert.ToInt32(Request.QueryString["EmployeeId"])
                });

                ContractNumberTextBox.Text = employeeView.EmployeeNo.Replace("AKP", "") + " / " + ctemplate.Preffix + " / " + s;
            }
            Generate();
        }
示例#12
0
        public async Task <int> CreateAsync(CreateEmployeeDto request)
        {
            Require.IsNotNull(request);

            try
            {
                Employee employee = EmployeeMapper.ToEntity(request) ?? throw new ArgumentNullException(nameof(request));

                if (await _employeeRepository.AnyAsync(x => x.EmployeeIdNumber.Equals(request.EmployeeIdNumber)))
                {
                    throw new ValidationException($"EmployeeIdNumber : {request.EmployeeIdNumber} already exists.");
                }

                if (await _employeeRepository.AnyAsync(x => x.Email.Equals(request.Email)))
                {
                    throw new ValidationException($"Email : {request.Email} already exists.");
                }

                _employeeRepository.Add(employee);

                return(await _unitOfWork.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex, "Error when EmployeeService.CreateAsync");
                throw;
            }
        }
示例#13
0
        public CascadingDropDownNameValue[] GetEmployeesByOrganisationalUnit(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

            List <CascadingDropDownNameValue> values = new List <CascadingDropDownNameValue>();

            int organisationalId;

            if (!kv.ContainsKey("OrganizationalUnit") ||
                !Int32.TryParse(kv["OrganizationalUnit"], out organisationalId))
            {
#warning change this code to get ur organisation unit and also do not display yourself
                //Get my organizational unit
                int myorganizationUnit   = 20;
                List <EmployeeView> list = new EmployeeMapper().ListWithAdvancedFilter("", "", null, myorganizationUnit, null, StatusEnum.Active);
                foreach (EmployeeView ent in list)
                {
                    CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.ToString(), ent.Id.ToString());
                    values.Add(cdnv);
                }
            }
            else
            {
                List <EmployeeView> list = new EmployeeMapper().ListWithAdvancedFilter("", "", null, organisationalId, null, StatusEnum.Active);
                foreach (EmployeeView ent in list)
                {
                    CascadingDropDownNameValue cdnv = new CascadingDropDownNameValue(ent.ToString(), ent.Id.ToString());
                    values.Add(cdnv);
                }
            }
            return(values.ToArray());
        }
示例#14
0
        public IActionResult SaveEmployee(EmployeeModel employeeModel)
        {
            if (ModelState.IsValid == false)
            {
                return(Content("Model is invalid"));
            }

            EmployeeMapper mapper   = new EmployeeMapper();
            Employee       employee = mapper.Map(employeeModel);

            //ERROR: employee.Creator = CurrentUser;

            if (employee.Id != 0)
            {
                DB.EmployeeRepository.Update(employee);
            }
            else
            {
                DB.EmployeeRepository.Add(employee);
            }

            TempData["Message"] = "Saved successfully";

            return(RedirectToAction("Index"));
        }
示例#15
0
        public async Task <IActionResult> Put(int id, [FromBody] EmployeeSaveRequestDto dto)
        {
            var employee = EmployeeMapper.Map(dto);
            await _employeeUpdater.UpdateAsync(id, employee);

            return(Ok());
        }
        public async Task SendRiskFactor(int idEmpleado, DateTime fecha, IEnumerable <RequestValue> values)
        {
            string url = String.Concat(DataConstants.Endpoint, DataConstants.SendRiskFactorURL);

            RequestRiskFactor request = new RequestRiskFactor()
            {
                idEmployee       = idEmpleado,
                fechaFactor      = fecha.ToString(EmployeeMapper.DATEFORMAT),
                riskFactorValues = EmployeeMapper.MapRequestRiskFactorValueDataList(values)
            };

            var response = await MakeSessionHttpCall <BaseResponse, RequestRiskFactor>(url, HttpVerbMethod.Post, request)
                           .ConfigureAwait(false);

            if (response.HasError)
            {
                if (response.info != null && response.info.Count() > 0)
                {
                    response.Message = String.Join("\n", response.info.Select(x => x.message));
                }
                throw new ApiException()
                      {
                          Code  = response.status,
                          Error = response.Message
                      };
            }
        }
示例#17
0
        public IActionResult Create()
        {
            var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees());
            var mappedOrders    = OrderMapper.MapManyToViewModel(orderService.GetOrders());

            return(View(new ProtocolCreateViewModel(mappedEmployees, mappedOrders)));
        }
示例#18
0
        public ActionResult Edit(EmployeeViewModel employee)
        {
            if (ModelState.IsValid)
            {
                switch (employee.EditMode)
                {
                case EditState.UpdateEmployeeAndUser:
                    _unitOfWork.Employee_List.UpdateWithUser(EmployeeMapper.Map(employee),
                                                             _unitOfWork.Person_List.GetRoleNameForUserId(User.Identity.GetUserId()));
                    this.Ok();
                    return(RedirectToAction("Index", "Employee", null));

                case EditState.UpdateEmployeeCreateUser:
                    _unitOfWork.Employee_List.UpdateAndCreateUser(EmployeeMapper.Map(employee),
                                                                  _unitOfWork.Person_List.GetRoleNameForUserId(User.Identity.GetUserId()), employee.Password);
                    this.Ok();
                    return(RedirectToAction("Index", "Employee", null));

                case EditState.UpdateEmployee:
                    _unitOfWork.Employee_List.Update(EmployeeMapper.Map(employee));
                    this.Ok();
                    return(RedirectToAction("Index", "Employee", null));

                default:
                    break;
                }
            }

            Forbidden();
            return(Content(GenerateError()));
        }
        public ActionResult <IEnumerable <EmployeeModel> > Get()
        {
            EmployeeService        empService = new EmployeeService(this._context);
            IEnumerable <Employee> result     = empService.GetAll();

            return(Ok(result.Select(a => EmployeeMapper.toModel(a))));
        }
        public ActionResult <IEnumerable <EmployeeModel> > Get(Guid departmentId)
        {
            EmployeeService        empService = new EmployeeService(this._context);
            IEnumerable <Employee> result     = empService.GetByDepartment(departmentId);

            return(Ok(result.Select(a => EmployeeMapper.toModel(a))));
        }
示例#21
0
        public ActionResult GetEmployeeId(int id)
        {
            var employee          = _employee.GetEmployeeById(id);
            var serializeEmployee = EmployeeMapper.SerializeEmployee(employee);

            return(PartialView(serializeEmployee));
        }
示例#22
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Email,PhoneNumber,Position,Salary,AddressID")] EmployeesViewModel employee)
        {
            if (id != employee.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(EmployeeMapper.MapViewToEmployee(employee));
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
示例#23
0
        public async Task <IActionResult> InsertEmployee([FromBody] Entities.Concrete.Employee.Employee employeeRequest)
        {
            ActionResultResponse <EmployeeResponse> response;

            Entities.Concrete.Employee.Employee employee = null;
            try
            {
                if (_service.ValidateEmployee(employeeRequest.CompanyID, employeeRequest.UserName, false))
                {
                    if (_service.InsertEmployee(employeeRequest))
                    {
                        employee = _service.GetEmployeeByCompanyID(employeeRequest.CompanyID);
                    }
                    response = EmployeeMapper.EmployeeGetByIdResult(employee);
                }
                else
                {
                    response = new ActionResultResponse <EmployeeResponse>(System.Net.HttpStatusCode.Locked, MessageException.GetEmployeeAlreadyExists(employeeRequest.CompanyID, employeeRequest.UserName), null);
                }
            }
            catch (Exception ex)
            {
                LogException.WriteLog(ex, "EmployeeController.InsertEmployee", JsonSerializer.Serialize(employeeRequest), LogType.Error);
                response = new ActionResultResponse <EmployeeResponse>(System.Net.HttpStatusCode.InternalServerError, MessageException.GetGeneralMessage(ex), null);
            }
            return(GetResponse(response));
        }
示例#24
0
        public async Task <IActionResult> Post([FromBody] EmployeeSaveRequestDto dto)
        {
            var employee = EmployeeMapper.Map(dto);
            await _employeeCreator.CreateAsync(employee);

            return(Ok());
        }
        public EmployeeModel Get(int id)
        {
            var employeeModel = EmployeeMapper.ToModel(UnitOfWork.Employees
                                                       .GetById(id));

            return(employeeModel);
        }
示例#26
0
        public IActionResult Create()
        {
            var mappedEmployees = EmployeeMapper.MapManyToViewModel(employeeService.GetEmployees());
            var mappedClients   = ClientMapper.MapManyToViewModel(clientService.GetClients());
            var mappedProducts  = ProductMapper.MapManyToViewModel(productService.GetProducts());

            return(View(new OrderCreateViewModel(mappedEmployees, mappedClients, mappedProducts)));
        }
示例#27
0
        public ActionResult Update(int id)
        {
            ViewBag.CompanyList = new SelectList(_company.GetCompanies(), "Id", "Name");
            var employee          = _employee.GetEmployeeById(id);
            var serializeEmployee = EmployeeMapper.SerializeEmployee(employee);

            return(PartialView(serializeEmployee));
        }
示例#28
0
        public async Task UpdateEmployeeAsync(Employee employee)
        {
            var employeeDb = EmployeeMapper.Map(employee);

            defaultDbContext.EmployeeDbs.Update(employeeDb);

            await defaultDbContext.SaveChangesAsync().ConfigureAwait(false);
        }
示例#29
0
        static void Main(string[] args)
        {
            Employee      emp     = new EmployeeMapper().Get("1037");
            AccountMapper am      = new AccountMapper();
            Account       account = new Account(emp, am.GetAccounts());

            am.Insert(account);
            Console.ReadLine();
        }
示例#30
0
        public EmployeeView()
        {
            _context = Application.Current.Properties["Workspace"] as IUnitOfWork;
            var employeeList = Task.Run(async() => await _context.EmployeeRepository.GetAll()).Result;

            Items = new ObservableCollection <EmployeeViewModel>(EmployeeMapper.DoListMap(employeeList));
            InitializeComponent();

            MyListView.ItemsSource = Items;
        }
示例#31
0
        static void Main(string[] args)
        {
            //create mapper instance
            EmployeeMapper em = new EmployeeMapper();

            // Get the same employee twice
            Employee emp1 = em.GetById(1);
            Employee emp2 = em.GetById(1);

            // check that the same object is returned by each call
            bool sameobject1 = emp1.Equals(emp2);

            // Get all hourly paid employees
            List<Employee> hpes = em.GetAllHourlyPaid();

            // Check that objects are not duplicated (may need to change these to match your data)
            // first hpe has empl1 as supervisor
            bool sameobject2 = emp1.Equals(hpes[0].Supervisor);         //  S/B TRUE
            // second hpe has first hpe as supervisor       NO DATA Has not been retrieved for this supervisor, although it's in the identity Map.
            bool sameobject3 = hpes[0].Equals(hpes[1].Supervisor);      //  S/B FALSE

            //  Get the supervisor for hpes[1], should have Id of 3
            Employee emp3 = em.GetById(3);
            bool sameobject4 = emp3.Equals(hpes[1].Supervisor);         //  S/B TRUE

            // Create a new hourly paid employee
            HourlyPaidEmployee newhpe = new HourlyPaidEmployee();
            Address newaddress = new Address("Entity Park", 100, new PostCode("KA1 1BX"));
            newhpe.Address = newaddress;
            newhpe.Name = "Michael";
            newhpe.Username = "******";
            newhpe.PhoneNumber = "2222";
            newhpe.Supervisor = emp1;

            // store and retrieve - object from database should have ID set
            int newID = em.StoreHourlyPaid(newhpe);
            Employee newEmp = em.GetById(newID);

            // set break point here and inspect objects with debugger
            Console.ReadLine();
        }
 public void Setup()
 {
     sut = new EmployeeMapper();
 }
 static MapperRegistry()
 {
     Employees = new EmployeeMapper();
     Skills = new SkillMapper();
 }