示例#1
0
 private static Cuisine FromRow(CuisineRow row)
 {
     return(new Cuisine(
                new CuisineId(row.Id),
                row.Name
                ));
 }
示例#2
0
        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));
        }
示例#3
0
 private static void ToRow(Cuisine obj, CuisineRow row)
 {
     row.Id   = obj.Id.Value;
     row.Name = obj.Name;
 }