public virtual void UpdateData(InternDetailsDto newintern, Company company) { //PersonType = newintern.PersonType; FName = newintern.Firstname; LName = newintern.Lastname; DateOfBirth = newintern.BirthDate; Company = company; AverageMark = newintern.AverageMark; }
internal void ConvertToDto(InternDetailsDto newinterndto) { newinterndto.Id = Id; newinterndto.PersonType = PersonType; newinterndto.Firstname = Firstname; newinterndto.Lastname = Firstname; newinterndto.BirthDate = BirthDate; newinterndto.City = City; newinterndto.Street = Street; newinterndto.AverageMark = AverageMark; newinterndto.CompanyId = CompanyId; }
public ActionResult EditIntern(long id, InternModel editedIntern) { if (ModelState.IsValid) { var newIntern = new InternDetailsDto(); editedIntern.ConvertToDto(newIntern); var currentIntern = PersonRepository.GetItemById<Intern>(id); var currentAddress = AddressRepository.GetItemById<Address>(currentIntern.Address.Id); AddressRepository.UpdateAddress(currentAddress, editedIntern.City, editedIntern.Street); var newCompany = CompanyRepository.GetItemById<Company>(newIntern.CompanyId); PersonRepository.UpdateIntern(currentIntern, newIntern, newCompany); var pers = PersonRepository.GetAllFirstAndLastNames(); return PartialView("WorkerList", pers); } return PartialView(editedIntern); }
public void UpdateIntern(Person currentintern, InternDetailsDto newintern, Company company) { using (var transaction = _session.BeginTransaction()) { try { var intern = (Intern) currentintern; intern.UpdateData(newintern, company); transaction.Commit(); } catch (Exception ex) { Logger.Logger.AddToLog("PersonRepository | UpdateIntern | {0}", ex); transaction.Rollback(); } } }