public async Task AddShopAsync(ClaimsPrincipal user, ShopViewModel shopViewModel) { Shop shop = new Shop(); var addressData = new AddressData { Address = shopViewModel.Address, City = shopViewModel.City.ToUpper(), Country = "Italy" }; var gls = new GoogleLocationService(); var latlong = gls.GetLatLongFromAddress(addressData); var latitude = latlong.Latitude; var longitude = latlong.Longitude; shop.Name = shopViewModel.Name; shop.ShortDesc = shopViewModel.ShortDesc; shop.City = shopViewModel.City; shop.Address = shopViewModel.Address; shop.Website = shopViewModel.Website; shop.Phone = shopViewModel.Phone; shop.Latitude = latitude; shop.Longitude = longitude; shop.InsertDate = DateTime.Now; shop.InsertUserId = user.GetUserId(); shop.UserId = user.GetUserId(); _dbContext.Shop.Add(shop); await _dbContext.SaveChangesAsync(); }
public async Task AddPuzzleAsync(ClaimsPrincipal user, string puzzleImageId, int distance, int shopId) { Puzzle newPuzzle = new Puzzle(); newPuzzle.PuzzleImage = puzzleImageId; newPuzzle.Distance = distance; newPuzzle.InsertDate = DateTime.Now; newPuzzle.InsertUserId = user.GetUserId(); newPuzzle.ShopId = shopId; newPuzzle.Status = (int)EnumHelper.PuzzleStatus.ToApprove; _dbContext.Puzzle.Add(newPuzzle); await _dbContext.SaveChangesAsync(); }