Exemplo n.º 1
0
        /// <see cref="IPersonService.GetListDescriptions" />
        public IEnumerable <PersonDescriptionModel> GetListDescriptions(int id)
        {
            var list = PersonModelHelper.GetDescriptionModels(_personRepository.GetDescriptions(id));

            foreach (var item in list)
            {
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePersonDescription(item.id_Person, item.Id));
            }
            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add or Update Person entity
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ServiceResponce SavePerson(PersonModel model, int userId)
        {
            var person   = PersonModelHelper.GetPerson(model);
            var res      = _personRepository.SavePerson(person, userId);
            var response = res != null?ServiceResponce
                           .FromSuccess()
                           .Result("Person save")
                           .Add("PersonId", person.Id) : ServiceResponce.FromFailed().Result("Error save person");

            return(response);
        }
Exemplo n.º 3
0
        /// <see cref="IPersonService.GetFacts" />
        public IEnumerable <PersonFactModel> GetFacts(int id)
        {
            var list = PersonModelHelper.GetFactModels(_personRepository.GetPersonFacts(id));

            foreach (var item in list)
            {
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePersonFact(item.id_Person, item.Id));
            }
            //var types = list.GroupBy(o => o.id_FactType).Select(o => o.Key);
            //return types.Select(tp => new EntityCollection<PersonFactModel> { List = list.Where(o => o.id_FactType == tp), Type = tp });
            return(list);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Возвращает список моделей описаний
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable <EntityCollection <PersonDescriptionModel> > GetDescriptions(int id)
        {
            var list = PersonModelHelper.GetDescriptionModels(_personRepository.GetDescriptions(id));

            foreach (var item in list)
            {
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePersonDescription(item.id_Person, item.Id));
            }
            var types = list.GroupBy(o => o.id_DescriptionType).Select(o => o.Key);

            return(types.Select(tp => new EntityCollection <PersonDescriptionModel> {
                List = list.Where(o => o.id_DescriptionType == tp), Type = tp
            }));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Возвращает список моделей антропометрических характеристик
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IList <PersonAntroModel> GetPersonAntros(int id)
        {
            var result = PersonModelHelper.GetPersonAntroModels(_personRepository.GetPersonAntros(id));

            foreach (var item in result)
            {
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePersonAntro(item.IdPerson, item.Id));
                item.Links      = new LinksModel
                {
                    PersonLinks = PersonModelHelper.GetPersonModels(_personRepository.GetAntroPersonLinks(item.Id)),
                    EventLinks  = EventModelHelper.GetEventModels(_personRepository.GetAntroEventLinks(item.Id))
                };
            }
            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Воозвращает всех Persons
        /// </summary>
        /// <returns></returns>
        public IList <PersonModel> GetAll()
        {
            var persons    = _personRepository.FindAllPerson();
            var listPerson = PersonModelHelper.GetPersonModels(persons);

            foreach (var item in listPerson)
            {
                var models = _personRepository.GetConnections(item.Id);
                item.Connections = PersonModelHelper.GetConnectionModels(models);
                var con = item.Connections.FirstOrDefault(o => o.Event != null);
                item.EventName  = con?.Event?.Name;
                item.EventType  = con?.Event?.EventCategory;
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePerson(item.Id));
            }
            return(listPerson);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Возвращает страницу списка Persons с учетом параметров поиска <paramref name="searchParams"/>
        /// </summary>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="searchParams"></param>
        /// <returns></returns>
        public IList <PersonModel> GetPersons(int pageNumber, int pageSize, PersonSearchParams searchParams = null)
        {
            var page       = new PageInfo(pageNumber, pageSize);
            var sex        = searchParams?.SexId;
            var persons    = _personRepository.FindPerson(page, searchParams?.Alphabetically, sex);
            var listPerson = PersonModelHelper.GetPersonModels(persons);

            foreach (var item in listPerson)
            {
                var models = _personRepository.GetConnections(item.Id);
                item.Connections = PersonModelHelper.GetConnectionModels(models);
                var con = item.Connections.FirstOrDefault(o => o.Event != null);
                item.EventName  = con?.Event?.Name;
                item.EventType  = con?.Event?.EventCategory;
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePerson(item.Id));
            }
            return(listPerson);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Возвращает список моделей медиа
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable <EntityCollection <PersonMediaModel> > GetMedia(int id)
        {
            var list = PersonModelHelper.GetMediaModels(_personRepository.GetMedia(id));

            foreach (var item in list)
            {
                item.LastChange = LogModelHelper.GetLastChangeModel(_logRepository.GetLastChangePersonMedia(item.id_Person, item.Id));
                item.Tags       = TagModelHelper.GeTagModels(_tagRepository.GetPersonMediaTags(item.Id));
                item.Links      = new LinksModel
                {
                    PersonLinks = PersonModelHelper.GetPersonModels(_personRepository.GetMediaPersonLinks(item.Id)),
                    EventLinks  = EventModelHelper.GetEventModels(_personRepository.GetMediaEventLinks(item.Id))
                };
            }
            var types = list.GroupBy(o => o.id_MediaType).Select(o => o.Key);

            return(types.Select(tp => new EntityCollection <PersonMediaModel> {
                List = list.Where(o => o.id_MediaType == tp), Type = tp
            }));
        }
Exemplo n.º 9
0
        /// <see cref="IPersonService.GetFactsTypes"/>
        public IList <PersonFactTypeModel> GetFactsTypes()
        {
            var result = _personRepository.GetPersonFactTypes();

            return(PersonModelHelper.GetFactTypeModels(result));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Воозвращает модель PersonModel по <paramref name="id"/>
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public PersonModel GetPerson(int id)
        {
            var result = _personRepository.FindPersonById(id);

            return(PersonModelHelper.GetPersonModel(result));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Возвращает список типов описаний
        /// </summary>
        /// <returns></returns>
        public IList <PersonDescriptionTypeModel> GetDescriptionTypes()
        {
            var result = _personRepository.GetDescriptionTypes();

            return(PersonModelHelper.GetDescriptionTypeModels(result));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Возвращает список типов медиа
        /// </summary>
        /// <returns></returns>
        public IList <MediaTypeModel> GetMediaTypes()
        {
            var result = _personRepository.GetMediaTypes();

            return(PersonModelHelper.GetMediaTypeModels(result));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Возвращает список типов ссылок
        /// </summary>
        /// <returns></returns>
        public IList <PersonSocialLinkTypeModel> GetSocialLinkTypes()
        {
            var result = _personRepository.GetLinkTypes();

            return(PersonModelHelper.GetSocialLinkTypeModels(result));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Возвращает список названий антропометрических характеристик
        /// </summary>
        /// <returns></returns>
        public IList <PersonAntroNameModel> GetAntroNames()
        {
            var result = _personRepository.GetAntroNames();

            return(PersonModelHelper.GetPersonAntroNameModels(result));
        }
Exemplo n.º 15
0
        /// <see cref="IPersonService.GetCountryPlaces(int, string)"/>
        public IList <CountryPlaceModel> GetCountryPlaces(int idCountry, string foundName)
        {
            var result = _personRepository.GetCountryPlaces(idCountry, foundName);

            return(PersonModelHelper.GetCountryPlaceModels(result));
        }
Exemplo n.º 16
0
        /// <see cref="IPersonService.GetCountries"/>
        public IList <CountryModel> GetCountries(string foundName)
        {
            var result = _personRepository.GetCountries(foundName);

            return(PersonModelHelper.GetCountryModels(result));
        }