Esempio n. 1
0
        public BludoModel GetElement(int id)
        {
            BludoModel element = GetList().Find(rec => rec.Id == id);

            if (element != null)
            {
                return(element);
            }
            throw new Exception("Элемент не найден");
        }
Esempio n. 2
0
        public void AddElement(BludoModel model)
        {
            Bludo element = context.Bludoes.FirstOrDefault(rec => rec.BludoName == model.BludoName);

            if (element != null)
            {
                throw new Exception("Уже есть блюдо с таким названием");
            }
            context.Bludoes.Add(new Bludo
            {
                BludoName = model.BludoName,
                Rezepts   = model.Rezepts.Select(rec => new Rezept
                {
                    Id            = rec.Id,
                    RezeptName    = rec.RezeptName,
                    RezeptData    = rec.RezeptData,
                    Ingrid        = rec.Ingrid,
                    soder         = rec.soder,
                    Image         = rec.Image,
                    ImageMimeType = rec.ImageMimeType
                }).ToList()
            });
            context.SaveChanges();
        }