예제 #1
0
        // POST: odata/Allergenes
        public IHttpActionResult Post(Allergene allergene)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Allergene.Add(allergene);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (AllergeneExists(allergene.allergene_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(allergene));
        }
예제 #2
0
 public AdminAllergeneModel(int id)
 {
     AlleAllergene = new List <Allergene>();
     using (GastroEntities _db = new GastroEntities())
     {
         AlleAllergene = (from Allergene al in _db.Allergene select al).ToList();
         AllergenItem  = AlleAllergene.Where(x => x.id == id).FirstOrDefault();
     }
 }
예제 #3
0
 public AdminAllergeneModel()
 {
     AlleAllergene = new List <Allergene>();
     using (GastroEntities _db = new GastroEntities())
     {
         AlleAllergene   = (from Allergene al in _db.Allergene select al).ToList();
         AllergenItem    = new Allergene();
         AllergenItem.id = 0;
     }
 }
예제 #4
0
        // DELETE: odata/Allergenes(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            Allergene allergene = db.Allergene.Find(key);

            if (allergene == null)
            {
                return(NotFound());
            }

            db.Allergene.Remove(allergene);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #5
0
        // PUT: odata/Allergenes(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <Allergene> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Allergene allergene = db.Allergene.Find(key);

            if (allergene == null)
            {
                return(NotFound());
            }

            patch.Put(allergene);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllergeneExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(allergene));
        }
예제 #6
0
 public AdminI18nAllergeneModel(int typId, int allergenId)
 {
     using (GastroEntities _db = new GastroEntities())
     {
         // 1 - Deutsch
         // 2 - Italienisch
         // 3 - Spanisch
         // 4 - Russisch
         // 5 - Englisch
         Allergene all = (from Allergene al in _db.Allergene where al.id == allergenId select al).FirstOrDefault();
         Deutsch_Beschreibung = all.Beschreibung;
         Deutsch_Bezeichnung  = all.Bezeichnung;
         liste = (from I18n i18n in _db.I18n where i18n.Typ == typId && i18n.AllergenId == allergenId select i18n).ToList();
         Englisch_Bezeichnung     = (from I18n x in liste where x.SprachId == 5 select x.Bezeichnung).FirstOrDefault();
         Englisch_Beschreibung    = (from I18n x in liste where x.SprachId == 5 select x.Beschreibung).FirstOrDefault();
         Italienisch_Bezeichnung  = (from I18n x in liste where x.SprachId == 2 select x.Bezeichnung).FirstOrDefault();
         Italienisch_Beschreibung = (from I18n x in liste where x.SprachId == 2 select x.Beschreibung).FirstOrDefault();
         Spanisch_Bezeichnung     = (from I18n x in liste where x.SprachId == 3 select x.Bezeichnung).FirstOrDefault();
         Spanisch_Beschreibung    = (from I18n x in liste where x.SprachId == 3 select x.Beschreibung).FirstOrDefault();
         Russisch_Bezeichnung     = (from I18n x in liste where x.SprachId == 4 select x.Bezeichnung).FirstOrDefault();
         Russisch_Beschreibung    = (from I18n x in liste where x.SprachId == 4 select x.Beschreibung).FirstOrDefault();
         AllergenId = allergenId;
     }
 }