public virtual void UpdateData(ContractorDetailsDto newcontractor, Company newcompany) { //PersonType = newintern.PersonType; FName = newcontractor.Firstname; LName = newcontractor.Lastname; DateOfBirth = newcontractor.BirthDate; Company = newcompany; //Salary.Amount = newcontractor.Salary; WorkExp = newcontractor.WorkExp; }
internal void ConvertToDto(ContractorDetailsDto newContractor) { newContractor.Id = Id; newContractor.PersonType = PersonType; newContractor.Firstname = Firstname; newContractor.Lastname = Firstname; newContractor.BirthDate = BirthDate; newContractor.City = City; newContractor.Street = Street; newContractor.Salary = Salary; newContractor.WorkExp = WorkExp; newContractor.CompanyId = CompanyId; }
public void UpdateContractor(Person currentContractor, ContractorDetailsDto newContractor, Company newCompany, Salary currentSalary) { using (var transaction = _session.BeginTransaction()) { try { var contractor = (Contractor)currentContractor; contractor.UpdateData(newContractor, newCompany); currentSalary.ChangeSalary(newContractor.Salary); transaction.Commit(); } catch (Exception ex) { Logger.Logger.AddToLog("PersonRepository | UpdateIntern | {0}", ex); transaction.Rollback(); } } }
public ActionResult EditContractor(long id, ContractorModel editedContractor) { if (ModelState.IsValid) { var newContractor = new ContractorDetailsDto(); editedContractor.ConvertToDto(newContractor); var currentContractor = PersonRepository.GetItemById <Contractor>(id); var currentAddress = AddressRepository.GetItemById <Address>(currentContractor.Address.Id); AddressRepository.UpdateAddress(currentAddress, editedContractor.City, editedContractor.Street); var newCompany = CompanyRepository.GetItemById <Company>(newContractor.CompanyId); var currentsalary = PersonRepository.GetItemById <Salary>(currentContractor.Salary.Id); PersonRepository.UpdateContractor(currentContractor, newContractor, newCompany, currentsalary); var pers = PersonRepository.GetAllFirstAndLastNames(); return(PartialView("WorkerList", pers)); } return(PartialView(editedContractor)); }
public ActionResult EditContractor(long id, ContractorModel editedContractor) { if (ModelState.IsValid) { var newContractor = new ContractorDetailsDto(); editedContractor.ConvertToDto(newContractor); var currentContractor = PersonRepository.GetItemById<Contractor>(id); var currentAddress = AddressRepository.GetItemById<Address>(currentContractor.Address.Id); AddressRepository.UpdateAddress(currentAddress, editedContractor.City, editedContractor.Street); var newCompany = CompanyRepository.GetItemById<Company>(newContractor.CompanyId); var currentsalary = PersonRepository.GetItemById<Salary>(currentContractor.Salary.Id); PersonRepository.UpdateContractor(currentContractor, newContractor, newCompany, currentsalary); var pers = PersonRepository.GetAllFirstAndLastNames(); return PartialView("WorkerList", pers); } return PartialView(editedContractor); }