Exemplo n.º 1
0
 internal void Import(DishDetailsRawDataItem item)
 {
     if (HasImport(item)) //不重复导入
     {
         return;
     }
     if (item.Name.IsNotNullOrEmpty() &&
         item.DataId.IsNotNullOrEmpty())
     {
         Dish dish = FromRawData(item);
         _dishRepository.Insert(dish);
     }
 }
Exemplo n.º 2
0
 private Dish FromRawData(DishDetailsRawDataItem item)
 {
     return(new Dish()
     {
         ImportId = item.DataId,
         Description = item.Name.ToUTF8(),
         HPhoto = item.SmallImageLocalPath().ToSlash(),
         BPhoto = item.BigImageLocalPath().ToSlash(),
         DishCategory = item.Tags,
         Taste = item.Taste,
         CookTime = item.CookTime,
         Difficulty = item.Difficulty,
         CookMethod = item.Technology,
         Cookerys = GetCookerys(item),
         DishBoms = GetDishBoms(item.DishBom, item.AuxDishBom),
     });
 }
Exemplo n.º 3
0
        private ICollection <Cookery> GetCookerys(DishDetailsRawDataItem item)
        {
            if (item.Cookery == null)
            {
                return(null);
            }

            foreach (var r in item.Cookery)
            {
                r.Content = r.Content.ToUTF8();
            }

            int start = 1;

            return(item.Cookery.Select(r => new Cookery()
            {
                Description = "abc",//r.Content.Substring(0, r.Content.Length > 30 ? 30 : r.Content.Length),
                Content = r.Content,
                Photo = item.CookeryLocalPath(start).ToSlash(),
                Order = start++,
            }).ToList());
        }
Exemplo n.º 4
0
 private bool HasImport(DishDetailsRawDataItem item)
 {
     return(_dishRepository.Count(d => d.ImportId == item.DataId) > 0);
 }