Exemple #1
0
        // POST: api/Shops
        public async Task Post([FromBody] AddShopRequestViewModel addShopRequestViewModel)
        {
            using (var findShopContext = new FindShopContext())
            {
                findShopContext.Shops.Add(new Shop()
                {
                    Name = addShopRequestViewModel.Name
                });

                await findShopContext.SaveChangesAsync();
            }
        }
Exemple #2
0
        // PUT: api/Shops/5
        public async Task Put(Guid id, [FromBody] AddLocationRequestViewModel addLocationRequestViewModel)
        {
            using (var findShopContext = new FindShopContext())
            {
                findShopContext.Locations.Add(new Location()
                {
                    Address    = addLocationRequestViewModel.Address,
                    Country    = addLocationRequestViewModel.Country,
                    PostalCode = addLocationRequestViewModel.PostalCode,
                    Latitude   = addLocationRequestViewModel.Latitude,
                    Longitude  = addLocationRequestViewModel.Longitude,
                    Timestamp  = DateTimeOffset.UtcNow,
                    ShopId     = id
                });

                await findShopContext.SaveChangesAsync();
            }
        }