Esempio n. 1
0
 public virtual void UpdateDataEmp(EmployeeDetailsDto newEmployee, Company newcompany)
 {
     //PersonType = newintern.PersonType;
     FName = newEmployee.Firstname;
     LName = newEmployee.Lastname;
     DateOfBirth = newEmployee.BirthDate;
     Company = newcompany;
     //Salary.Amount = newcontractor.Salary;
     WorkExp = newEmployee.WorkExp;
     Role = newEmployee.Role;
     Department = newEmployee.Department;
 }
Esempio n. 2
0
 internal void ConvertToDto(EmployeeDetailsDto newEmployee)
 {
     newEmployee.Id = Id;
     newEmployee.PersonType = PersonType;
     newEmployee.Firstname = Firstname;
     newEmployee.Lastname = Firstname;
     newEmployee.BirthDate = BirthDate;
     newEmployee.City = City;
     newEmployee.Street = Street;
     newEmployee.Salary = Salary;
     newEmployee.WorkExp = WorkExp;
     newEmployee.CompanyId = CompanyId;
     newEmployee.Department = Department;
     newEmployee.Role = Role;
 }
Esempio n. 3
0
        public ActionResult EditEmployee(long id, EmployeeModel editedEmployee)
        {
            if (ModelState.IsValid)
            {
                var newEmployee = new EmployeeDetailsDto();
                editedEmployee.ConvertToDto(newEmployee);
                var currentEmployee = PersonRepository.GetItemById<Employee>(id);
                var currentAddress = AddressRepository.GetItemById<Address>(currentEmployee.Address.Id);
                AddressRepository.UpdateAddress(currentAddress, editedEmployee.City, editedEmployee.Street);
                var newCompany = CompanyRepository.GetItemById<Company>(newEmployee.CompanyId);
                var currentsalary = PersonRepository.GetItemById<Salary>(currentEmployee.Salary.Id);
                PersonRepository.UpdateEmployee(currentEmployee, newEmployee, newCompany, currentsalary);

                var pers = PersonRepository.GetAllFirstAndLastNames();
                return PartialView("WorkerList", pers);
            }

            return PartialView(editedEmployee);
        }
Esempio n. 4
0
 public void UpdateEmployee(Person currentEmployee, EmployeeDetailsDto newEmployee, Company newCompany, Salary currentSalary)
 {
     using (var transaction = _session.BeginTransaction())
     {
         try
         {
             var employee = (Employee)currentEmployee;
             employee.UpdateDataEmp(newEmployee, newCompany);
             currentSalary.ChangeSalary(newEmployee.Salary);
             transaction.Commit();
         }
         catch (Exception ex)
         {
             Logger.Logger.AddToLog("PersonRepository | UpdateIntern | {0}", ex);
             transaction.Rollback();
         }
     }
 }