Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 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();
         }
     }
 }
        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));
        }