Example #1
0
        public async Task <ActionResult <Main> > PostMain([FromBody] INPUT data)
        {
            Main   main;
            String geolcation;
            String type;

            try
            {
                // Constructing the video object from our helper function
                geolcation = data.GeoCode;
                type       = data.TypeOfPlace;
                main       = Map.GetPlaces(geolcation, type);
            }
            catch
            {
                return(BadRequest("Invalid"));
            }

            _context.Main.Add(main);
            await _context.SaveChangesAsync();

            int ide = main.MainId;

            placeConverterContext     a   = new placeConverterContext();
            PlaceConvertersController pcc = new PlaceConvertersController(a);

            Task addplace = Task.Run(async() =>
            {
                List <PlaceConverter> placearray = new List <PlaceConverter>();
                placearray = Map.GetPlacesFromGeoCodenType(geolcation, type);

                for (int i = 0; i < placearray.Count; i++)
                {
                    PlaceConverter pl = placearray.ElementAt(i);
                    pl.MainId         = ide;

                    await pcc.PostPlaceConverter(pl);
                }
            });



            return(CreatedAtAction("GetMain", new { id = main.MainId }, main));
        }
Example #2
0
 public PlaceConvertersController(placeConverterContext context)
 {
     _context = context;
 }