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(); }
public Shop CreateShop(Adress adress) { var shop = new Shop { Adress = adress }; if (adress != null) shop.AdressId = adress.Id; return shop; }
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); }