Example #1
0
 public ActionResult OtvoriFormu([Bind(Include = "ID,Vrsta,Tezina,Starost,Boja,Nadimak")] Stoka zivotinja)
 {
     if (ModelState.IsValid)
     {
         db.Zivotinje.Add(zivotinja);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View("Index", db.Zivotinje.ToList()));
 }
Example #2
0
        public ActionResult UrediZivotinju([Bind(Include = "ID,Vrsta,Starost,Tezina,Nadimak,Boja")] Stoka zivotinja)
        {
            if (ModelState.IsValid)
            {
                db.Set <Stoka>().AddOrUpdate(zivotinja);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(zivotinja));
        }
        static void Main(string[] args)
        {
            List <Stoka> list = new List <Stoka>();

            while (true)
            {
                string command = Console.ReadLine();
                if (command == "end")
                {
                    break;
                }
                if (command == "add")
                {
                    Stoka stoka = new Stoka();
                    Console.WriteLine("Vyvedete ime");
                    stoka.name = Console.ReadLine();
                    Console.WriteLine("Vyvedete cena");
                    stoka.price = decimal.Parse(Console.ReadLine());
                    Console.WriteLine("Vyvedete kolichestvo");
                    stoka.quantity = int.Parse(Console.ReadLine());
                    stoka.value    = (decimal)stoka.quantity * stoka.price;
                    list.Add(stoka);
                }
                if (command == "display")
                {
                    Console.WriteLine("vyvedete stoinost za sravneneie");
                    decimal filter = decimal.Parse(Console.ReadLine());
                    foreach (var item in list)
                    {
                        if (item.value > filter)
                        {
                            Console.WriteLine($"{item.name} : {item.quantity} + {item.price:f2} = {item.value}");
                        }
                    }
                }
            }
        }