Ejemplo n.º 1
0
        public IEnumerable <PictureDTO> GetImagesFromStreet([FromBody] StreetDTO Street, ImageProvider imageProvider = ImageProvider.Google)
        {
            var panoramaPoints = Street.Trechos.SelectMany(p => p).Where(p => p.PanoramaDTO != null && p.PanoramaDTO.pano != null);

            List <PictureDTO> Pictures = new List <PictureDTO>();

            foreach (var picNotNull in panoramaPoints)
            {
                var auxPic = picNotNull.PanoramaDTO.Pictures.ElementAt(0);
                auxPic.location = new PointDTO()
                {
                    ID = picNotNull.ID, lat = picNotNull.lat, lng = picNotNull.lng
                };
                Pictures.Add(auxPic);
            }

            foreach (var picture in Pictures)
            {
                try
                {
                    var         imageMinerManager = ImageMinerManager.getInstance();
                    IImageMiner imageMiner        = imageMinerManager.getImageMiner(imageProvider);
                    picture.base64image = imageMiner.getImageBase64(picture.imageURI);
                    //(new Models.Imagery.Google.GSMiner()).DownloadBase64ImageFromURI();
                }
                catch (Exception)
                {
                    picture.base64image = null;
                }
            }
            Pictures.RemoveAll(p => p.base64image == null);
            return(Pictures);
        }
Ejemplo n.º 2
0
        public IActionResult SearchStationsStreet(StreetDTO street)
        {
            List <PollingStation> pollingStations = _context.PollingStation.Where(ps => ps.StreetId == street.IdStreet).ToList().GroupBy(p => p.Name).Select(grp => grp.First()).ToList();

            if (pollingStations.Any())
            {
                int[] stationsId = pollingStations.Select(p => p.StationId ?? 0).ToArray();

                if (stationsId.Any())
                {
                    List <Station>    stations    = _context.Station.Where(s => stationsId.Contains(s.IdStation)).ToList();
                    List <StationDTO> stationDTOs = stations.Select(s => new StationDTO {
                        IdStation = s.IdStation, Name = s.Name
                    }).ToList();
                    stationDTOs.Insert(0, new StationDTO {
                        IdStation = 0, Name = ""
                    });
                    return(Ok(stationDTOs));
                }
                else
                {
                    return(NoContent());
                }
            }
            else
            {
                return(NoContent());
            }
        }
Ejemplo n.º 3
0
 private void validate(StreetDTO street)
 {
     if (string.IsNullOrEmpty(street.Name))
     {
         throw new ArgumentException("Name повинне містити значення!");
     }
 }
 public ActionResult Edit(StreetDTO obj)
 {
     if (ModelState.IsValid)
     {
         streetService.Add(obj);
         streetService.Save();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Ejemplo n.º 5
0
        [Route("AddStreet")]// לבדוק איך קוראים בר
        public IHttpActionResult AddStreet([FromBody] StreetDTO sDTO)
        {
            bool b = Bl.PropertyBL.AddStreet(sDTO);

            if (b == true)
            {
                return(Ok());
            }
            return(BadRequest());
        }
Ejemplo n.º 6
0
 public HttpResponseMessage Post(StreetDTO street)
 {
     try
     {
         streetService.Add(street);
         return(Request.CreateResponse(HttpStatusCode.OK, street));
     }
     catch (Exception exc)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Не смогли получить адрес"));
     }
 }
Ejemplo n.º 7
0
        public IActionResult SearchPollingStationsStreet(StreetDTO street)
        {
            List <PollingStation> pollingStations = _context.PollingStation.Where(ps => ps.StreetId == street.IdStreet).ToList().GroupBy(p => p.Name).Select(grp => grp.First()).ToList();

            if (pollingStations.Any())
            {
                List <PollingStationDTO> pollingStationsDTO = pollingStations.Select(p => new PollingStationDTO {
                    IdPollingStation = p.IdPollingStation, Name = p.Name
                }).ToList();
                return(Ok(pollingStationsDTO));
            }
            return(NoContent());
        }
Ejemplo n.º 8
0
        public IActionResult SearchHouse(StreetDTO streetSelected)
        {
            List <House>    houses    = _context.House.Where(h => h.StreetId == streetSelected.IdStreet).ToList <House>();
            List <HouseDTO> housesDTO = new List <HouseDTO>();

            if (houses.Any())
            {
                housesDTO = houses.Select(h => new HouseDTO {
                    IdHouse = h.IdHouse, Name = h.Name
                }).ToList();
                return(Ok(housesDTO));
            }
            return(Ok(housesDTO));
        }
Ejemplo n.º 9
0
 public ActionResult Create(StreetDTO street,
                            FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         unitOfWorkAddress.StreetService.Add(street);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 10
0
        public async Task CreateStreet(StreetDTO dto)
        {
            Guid id = Guid.NewGuid();

            using (MUEContext db = new MUEContext())
            {
                Street street = new Street {
                    StreetId    = id,
                    Name        = dto.Name,
                    Description = dto.Description
                };
                db.Streets.Add(street);
                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 11
0
        public IActionResult Get()
        {
            List <StreetDTO> lista = new List <StreetDTO>();

            foreach (Street item in data.Streets)
            {
                StreetDTO s = new StreetDTO();
                s.Id       = item.Id;
                s.Priority = item.Priority;
                s.Name     = item.Name;

                lista.Add(s);
            }

            return(Ok(new { lista }));
        }
Ejemplo n.º 12
0
 public ActionResult Edit(StreetDTO street, FormCollection collection)
 {
     using (unitOfWorkAddress.Transaction = new TransactionScope(TransactionScopeOption.RequiresNew))
     {
         try
         {
             unitOfWorkAddress.StreetService.Update(street);
             unitOfWorkAddress.Commit();
             return(RedirectToAction("Index"));
         }
         catch
         {
             unitOfWorkAddress.Rollback();
         }
     }
     return(View());
 }
Ejemplo n.º 13
0
        public void AddStreet(StreetDTO street)
        {
            var user     = SecurityContext.GetUser();
            var userType = user.GetType();

            if (userType != typeof(Director) ||
                userType != typeof(Accountant))
            {
                throw new MethodAccessException();
            }
            if (street == null)
            {
                throw new ArgumentNullException(nameof(street));
            }

            validate(street);

            var mapper       = new MapperConfiguration(cfg => cfg.CreateMap <StreetDTO, Street>()).CreateMapper();
            var streetEntity = mapper.Map <StreetDTO, Street>(street);

            _database.Streets.Create(streetEntity);
        }
        public ActionResult Edit(int id)
        {
            StreetDTO model = (id == 0) ? new StreetDTO() : streetService.Get(id);

            return(View(model));
        }
Ejemplo n.º 15
0
        public async Task <List <StreetDTO> > getStreets(Bound region)
        {
            List <StreetDTO>     ruasDetectadas = new List <StreetDTO>();
            OverpassQueryBuilder oqb            = new OverpassQueryBuilder(region);
            var sampleQuery = oqb.highwayOverpassQuery();

            try
            {
                string encodedURL = overpassUrl + HttpUtility.UrlEncode(sampleQuery);
                using (HttpClient client = new HttpClient())
                {
                    var responseString = await client.GetStringAsync(encodedURL);

                    OSMResult osm = JsonConvert.DeserializeObject <OSMResult>(responseString);
                    if (osm.GetWaysAsDictionary != null && osm.GetWaysAsDictionary.Count() > 0)
                    {
                        foreach (var way in osm.GetWaysAsDictionary)
                        {
                            if (!way.Value.tags.ContainsKey("name") || String.IsNullOrWhiteSpace(way.Value.tags["name"]))
                            {
                                continue;
                            }
                            var name         = way.Value.tags["name"];
                            var ruaExistente = ruasDetectadas.FirstOrDefault(p => p.Name.Equals(name));
                            var novoTrecho   = new List <PointDTO>();
                            if (ruaExistente != null)
                            {
                                foreach (var idNode in way.Value.nodes)
                                {
                                    var ponto = osm.GetNodesAsDictionary[idNode];
                                    novoTrecho.Add(new PointDTO()
                                    {
                                        ID = idNode.ToString(), lat = (float)ponto.lat, lng = (float)ponto.lon
                                    });
                                }
                                ruaExistente.Trechos.Add(novoTrecho);
                                //ruaExistente.Trechos = ruaExistente.Trechos.Distinct(new PointComparer()).ToList();
                                continue;
                            }

                            StreetDTO rua = new StreetDTO();
                            rua.Name = name;
                            foreach (var idNode in way.Value.nodes)
                            {
                                var ponto = osm.GetNodesAsDictionary[idNode];
                                novoTrecho.Add(new PointDTO()
                                {
                                    ID = idNode.ToString(), lat = (float)ponto.lat, lng = (float)ponto.lon
                                });
                            }
                            rua.Trechos.Add(novoTrecho);
                            //rua.Trechos = rua.Trechos.Distinct(new PointComparer()).ToList();
                            ruasDetectadas.Add(rua);
                        }
                    }



                    return(ruasDetectadas);
                }
            }
            catch (Exception ex)
            {
                return(new List <StreetDTO>()
                {
                    new StreetDTO()
                    {
                        Name = "Erro! " + ex.Message
                    }
                });
            }
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> Create(StreetDTO dto)
        {
            await buildingService.CreateStreet(dto);

            return(RedirectToAction("Streets", "Street"));
        }
Ejemplo n.º 17
0
 public static bool AddStreet(StreetDTO sDTO)
 {
     return(PropertyDAL.AddStreet(StreetDTO.ToDAL(sDTO)));
 }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            try
            {
                var kernel = new StandardKernel(new ServiceModule());

                StreetService      streetService  = kernel.Get <StreetService>();
                AddressService     addressService = kernel.Get <AddressService>();
                SubdivisionService subdivService  = kernel.Get <SubdivisionService>();

                Console.WriteLine("Get All");
                StreetDTO      s  = streetService.GetAll().ToList()[0];
                AddressDTO     a  = addressService.GetAll().ToList()[0];
                SubdivisionDTO sd = subdivService.GetAll().ToList()[0];

                Console.WriteLine("Works");
                //Console.WriteLine($"{s.StreetId}  {s.StreetName}");
                //Console.WriteLine($"{a.House} {a.Latitude} {a.Longitude} {a.Serial} {a.StreetId} {a.SubdivisionId} {a.СountEntrance} {a.СountFloor}");
                //Console.WriteLine($"{sd.SubdivisionId} {sd.SubdivisionName}");

                Console.WriteLine("");
                Console.WriteLine("Get");
                Console.WriteLine("Works");

                //s = streetService.Get(1);
                //a = addressService.Get(1);
                //sd = subdivService.Get(1);

                //Console.WriteLine($"{s.StreetId}  {s.StreetName}");
                //Console.WriteLine($"{a.House} {a.Latitude} {a.Longitude} {a.Serial} {a.StreetId} {a.SubdivisionId} {a.СountEntrance} {a.СountFloor}");
                //Console.WriteLine($"{sd.SubdivisionId} {sd.SubdivisionName}");

                Console.WriteLine("");
                Console.WriteLine("Add");
                Console.WriteLine("Works");

                s = new StreetDTO()
                {
                    StreetName = "Тестовая Улица 1"
                };
                a = new AddressDTO()
                {
                    House = "TestAddress1", Latitude = decimal.Zero, Longitude = decimal.Zero, Serial = "Test Serial1", StreetId = streetService.GetAll().Last().StreetId, SubdivisionId = subdivService.GetAll().Last().SubdivisionId, СountEntrance = 0, СountFloor = 0
                };
                sd = new SubdivisionDTO()
                {
                    SubdivisionName = "SubDiv Test1"
                };

                //Console.WriteLine(streetService.Add(s));
                //Console.WriteLine(addressService.Add(a).House);
                //Console.WriteLine(a.House);
                //Console.Write(addressService.GetAll().Where(g => g.House == a.House).FirstOrDefault().AddressId);
                //Console.WriteLine(subdivService.Add(sd));


                Console.WriteLine("");
                Console.WriteLine("Update");
                Console.WriteLine("Address update ?");
                //streetService.Update(new StreetDTO() { StreetId = streetService.GetAll().Last().StreetId, StreetName = "Updated Street" });

                //addressService.Update(new AddressDTO() { AddressId = addressService.GetAll().Last().AddressId, House = "Updated Address" });

                //subdivService.Update(new SubdivisionDTO() { SubdivisionId = subdivService.GetAll().Last().SubdivisionId, SubdivisionName = "Updated SubDiv" });

                //Console.WriteLine(streetService.GetAll().Last().StreetName);
                //Console.WriteLine(addressService.GetAll().Last().House);
                //Console.WriteLine(subdivService.GetAll().Last().SubdivisionName);


                Console.WriteLine("");
                Console.WriteLine("Delete");

                Console.WriteLine(streetService.Delete(streetService.GetAll().Last()).StreetName);
                Console.WriteLine(addressService.Delete(addressService.GetAll().Last()).House);
                Console.WriteLine(subdivService.Delete(subdivService.GetAll().Last()).SubdivisionName);



                Console.ReadKey();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 19
0
        public ActionResult Create()
        {
            var model = new StreetDTO();

            return(View(model));
        }