// маппит из Model в Entity public void PeopleModelMapToPeoples(PeopleViewModel source, ref People dest, bool isPeoplePart = false) { try { dest.Id = source.Id; dest.FirstName = source.FirstName; dest.LastName = source.LastName; dest.BirthDate = source.BirthDate; if (source.PhotoPeople == null) { dest.PhotoPeople = null; } else { dest.PhotoPeople = UtilHelper.HttpPostedFileBaseToByte(source.PhotoPeople); } if (source.PhotoMIMEType == null || source.PhotoPeople == null) { dest.PhotoMIMEType = ""; } else { dest.PhotoMIMEType = source.PhotoMIMEType; } List <PeopleAwards> lst = new List <PeopleAwards>(); if (isPeoplePart) { dest.PeopleAwards = lst; return; } List <ListPeopleAwardsViewModel> entList = source.PeopleAwards.ToList(); PeopleAwards peopleAward; foreach (var item in entList) { peopleAward = new PeopleAwards(); peopleAward.Id = item.Id; peopleAward.PeopleID = item.PeopleID; peopleAward.AwardID = item.AwardID; Awards award = new Awards(); award.Id = item.Award.Id; award.NameAward = item.Award.NameAward; award.DescriptionAward = item.Award.DescriptionAward; if (item.Award.PhotoAward != null) { award.PhotoAward = UtilHelper.HttpPostedFileBaseToByte(item.Award.PhotoAward); } award.PhotoMIMEType = item.Award.PhotoMIMEType; peopleAward.Award = award; lst.Add(peopleAward); } dest.PeopleAwards = lst; } catch (Exception ex) { Logger.LogException(new Exception(String.Format("Ошибка:\n{0}\n{1}\n{2}", ex.Message, ex.StackTrace, ex.InnerException.StackTrace))); throw ex; } }