Esempio n. 1
0
 public async Task CreateOrUpdate(Shop shop, string userId)
 {
     if (!string.IsNullOrEmpty(shop.Id))
     {
         _db.Entry(shop).State = EntityState.Modified;
     }
     else
     {
         shop.Id = Guid.NewGuid().ToString();
         var userShop = new UserShop { IdShop = shop.Id, IdUser = shop.Id };
         _db.Entry(shop).State = EntityState.Added;
         _db.Entry(userShop).State = EntityState.Added;
     }
     await _db.SaveChangesAsync();
 }
Esempio n. 2
0
 public Shop CreateShop(Adress adress)
 {
     var shop = new Shop { Adress = adress };
     if (adress != null) shop.AdressId = adress.Id;
     return shop;
 }
Esempio n. 3
0
 private async Task SaveShop(Shop shop, string userId)
 {
     shop.Adress = await AdressManager.GetOrCreateAdress(shop.Adress);
     var userShop = await AdressManager.GetShopByUserId(userId) ?? shop;
     userShop.AdressId = shop.Adress.Id;
     await AdressManager.CreateOrUpdate(userShop, userId);
 }