Esempio n. 1
0
 /// <summary>
 /// this method is for showing details of table
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 // GET: p/Details/5
 public ActionResult Details(int id)
 {
     using (dbmodel obj = new dbmodel())
     {
         return(View(obj.politics.Where(x => x.id == id).FirstOrDefault()));
     }
 }
Esempio n. 2
0
 // GET: p
 /// <summary>
 /// this Index() is for to show the description of table.
 /// </summary>
 /// <returns></returns>
 public ActionResult Index()
 {
     using (dbmodel obj = new dbmodel())
     {
         return(View(obj.politics.ToList()));
     }
 }
Esempio n. 3
0
        public ActionResult Edit(int id, politic collection)
        {
            try
            {
                using (dbmodel obj = new dbmodel())
                {
                    obj.Entry(collection).State = System.Data.Entity.EntityState.Modified;
                    obj.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 4
0
        public ActionResult Create(politic collection)
        {
            try
            {
                using (dbmodel obj = new dbmodel())
                {
                    obj.politics.Add(collection);
                    obj.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 5
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (dbmodel obj = new dbmodel())
                {
                    politic p = obj.politics.Where(x => x.id == id).FirstOrDefault();
                    obj.politics.Remove(p);
                    obj.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public EmployeesController(dbmodel context, IHostingEnvironment hostingEnvironment)
 {
     _context  = context;
     this._env = hostingEnvironment;
 }