private static Cuisine FromRow(CuisineRow row) { return(new Cuisine( new CuisineId(row.Id), row.Name )); }
public Task StoreAsync(Cuisine cuisine, CancellationToken cancellationToken = default) { return(Task.Factory.StartNew(() => { var dbSet = dbContext.Cuisines; var row = dbSet.FirstOrDefault(x => x.Id == cuisine.Id.Value); if (row != null) { ToRow(cuisine, row); dbSet.Update(row); } else { row = new CuisineRow(); ToRow(cuisine, row); dbSet.Add(row); } dbContext.SaveChanges(); }, cancellationToken)); }
private static void ToRow(Cuisine obj, CuisineRow row) { row.Id = obj.Id.Value; row.Name = obj.Name; }