public async Task <Item> AddSubscriberToItemAsync(Item item, string email) { ItemPOCO itemInDb = context.Items.First(i => i.Id == item.Id); if (itemInDb.SubscribersEmails.Contains(email)) { return(itemInDb.ToItem()); } itemInDb.SubscribersEmails = itemInDb.SubscribersEmails.Append(email).ToArray(); context.Items.Update(itemInDb); await context.SaveChangesAsync(); return(itemInDb.ToItem()); }
public async Task <Item> CreateItemAsync(string itemName, string url, string[] emails) { var itemToCreate = new ItemPOCO { Id = Guid.NewGuid().ToString(), Name = itemName, Url = url, SubscribersEmails = emails }; context.Items.Add(itemToCreate); await context.SaveChangesAsync(); return(itemToCreate.ToItem()); }