示例#1
0
        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));
        }
示例#3
0
        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));
            }
        }
示例#4
0
        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);
            }
        }