public override void SetModel(M_Base modelBase) { M_CalendarDate modelEntity = modelBase as M_CalendarDate; _model = modelEntity; Id = modelEntity.Id; Start = modelEntity.Start; End = modelEntity.End; NameEmployer = GetName(modelEntity.Employee?.PersonInfo); TypeDate = modelEntity.TypeDate; _employer = modelEntity?.Employee; }
//Потрібна оптимізація public M_Person FindEmployerWithName(string nameEmployer) { if (nameEmployer == null) { return(null); } string name, surname; M_PersonInfo tempInfo = new M_PersonInfo(); ViewModel.SetNamePerson(ref tempInfo, nameEmployer); name = tempInfo.NameFirst; surname = tempInfo.NameSecond; IGenericRepository <M_Person> repPerson = new UnitOfWork().RepositoryPerson; M_Person employer = repPerson .Get(emp => emp.PersonInfo.NameFirst == name && emp.PersonInfo.NameSecond == surname) .FirstOrDefault(); return(employer); }