Пример #1
0
        public IActionResult ApiGet()
        {
            var data = _repo
                       .AsQueryable()
                       .Include(c => c.Members)
                       .ToList();

            var model = new List <LocationModel>();

            data.ForEach(c =>
            {
                var locationModel = new LocationModel();

                locationModel.Id = c.Id;

                locationModel.Title = c.Title;

                var manger = c.Members.FirstOrDefault(i => i.Type == MemberType.Manager);

                locationModel.ManagerFullName = manger?.FullName;

                if (string.IsNullOrEmpty(manger?.PhoneNumbers))
                {
                    locationModel.ManagerPhoneNumbers = new List <string>();
                }
                else
                {
                    locationModel.ManagerPhoneNumbers = JsonConvert
                                                        .DeserializeObject <List <string> >(manger?.PhoneNumbers);
                }

                locationModel.CountSuccessor = c.Members.Where(i => i.Type == MemberType.Successor).Count();


                var successor = c.Members.Where(i => i.Type == MemberType.Successor).ToList();

                successor.ForEach(i =>
                {
                    locationModel.Successor.Add(new LocationMemberModel
                    {
                        FullName     = i.FullName,
                        Id           = i.Id,
                        LocationId   = i.LocationId,
                        PhoneNumbers = JsonConvert.DeserializeObject <List <string> >(i.PhoneNumbers)
                    });
                });

                model.Add(locationModel);
            });


            return(Ok(model));
        }
Пример #2
0
        public IQueryable GetDipendenti()
        {
            IRepository <Dipendente> repository = new BaseRepository <Dipendente>(null);

            return(repository.AsQueryable());
        }