Example #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Odb odb = db.Odbs.Find(id);

            db.Odbs.Remove(odb);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "VOppID,OName,ODate,OCenter,OSkills")] Odb odb)
 {
     if (ModelState.IsValid)
     {
         db.Entry(odb).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(odb));
 }
Example #3
0
        public ActionResult Create([Bind(Include = "VOppID,OName,ODate,OCenter,OSkills")] Odb odb)
        {
            if (ModelState.IsValid)
            {
                db.Odbs.Add(odb);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(odb));
        }
Example #4
0
        // GET: Opportunity/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Odb odb = db.Odbs.Find(id);

            if (odb == null)
            {
                return(HttpNotFound());
            }
            return(View(odb));
        }
Example #5
0
        static void Main(string[] args)
        {
            //Исходный код программы
            Dictionary <string, int> dict = new Dictionary <string, int>()
            {
                { "four", 4 },
                { "two", 2 },
                { "one", 1 },
                { "three", 3 },
            };
            var d = dict.OrderBy(delegate(KeyValuePair <string, int> pair) { return(pair.Value); });

            foreach (var pair in d)
            {
                Console.WriteLine("{0} - {1}", pair.Key, pair.Value);
            }
            //Использование лямбда-выражения
            Dictionary <string, int> dict1 = new Dictionary <string, int>()
            {
                { "four", 4 },
                { "two", 2 },
                { "one", 1 },
                { "three", 3 },
            };
            var d1 = dict1.OrderBy(d => d.Value);

            Console.WriteLine("Сортировка с использованием лямбда-выражения в запросе linq:");
            foreach (var pair in d1)
            {
                Console.WriteLine("{0} - {1}", pair.Key, pair.Value);
            }
            //Использование делегата
            //public delegate KeyValuePair<TKey,TValue>.Value Odb(KeyValuePair<TKey, TValue>);
            Odb sort = delegate(KeyValuePair <string, int> pair) { return(pair.Value); };
            Dictionary <string, int> dict2 = new Dictionary <string, int>()
            {
                { "four", 4 },
                { "two", 2 },
                { "one", 1 },
                { "three", 3 },
            };
            var d2 = dict2.OrderBy(dict2 => sort);

            Console.WriteLine("Сортировка с использованием развернутого делегата в запросе linq:");
            foreach (var pair in d2)
            {
                Console.WriteLine("{0} - {1}", pair.Key, pair.Value);
            }
        }