public static void Dodaj(Plan_Ishrane Item) { try { var collection = Connection <Plan_Ishrane> .getCollection(CollectionName); collection.Save(Item);; } catch (Exception e) { Console.WriteLine(e); } }
public ActionResult DodajPlanIshrane(string naziv) { Plan_Ishrane plan = new Plan_Ishrane { Naziv = naziv, Broj_Ocenjivanja = 0, Prosecna_Ocena = 9.0, }; PlanIshrane.Dodaj(plan); PlanIshraneModel model = new PlanIshraneModel(); return(View("~/Views/PlanIshrane/ListaPlanovaIshrane.cshtml", model)); }
static public Plan_Ishrane Procitaj(ObjectId id) { Plan_Ishrane found = new Plan_Ishrane(); try { var collection = Connection <Plan_Ishrane> .getCollection(CollectionName); return(collection.FindOneByIdAs <Plan_Ishrane>(id)); } catch (Exception e) { Console.WriteLine(e); return(default(Plan_Ishrane)); } }
static public void DodajObrok(ObjectId planId, MongoDBRef obrok) { try { var collection = Connection <Plan_Ishrane> .getCollection(CollectionName); Plan_Ishrane k = PlanIshrane.Procitaj(planId); k.Obroci.Add(obrok); collection.Save(k); } catch (Exception e) { Console.WriteLine(e); } }