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

            db.table_demographic.Remove(table_demographic);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Edit([Bind(Include = "D_id,Total_person,Male_count,Female_count,caste,religion,senior_id")] table_demographic table_demographic)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table_demographic).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.senior_id = new SelectList(db.table_house_senior_details, "senior_id", "Home_no", table_demographic.senior_id);
     return(View(table_demographic));
 }
Example #3
0
        // GET: demog/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            table_demographic table_demographic = db.table_demographic.Find(id);

            if (table_demographic == null)
            {
                return(HttpNotFound());
            }
            return(View(table_demographic));
        }
Example #4
0
        // GET: demog/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            table_demographic table_demographic = db.table_demographic.Find(id);

            if (table_demographic == null)
            {
                return(HttpNotFound());
            }
            ViewBag.senior_id = new SelectList(db.table_house_senior_details, "senior_id", "Home_no", table_demographic.senior_id);
            return(View(table_demographic));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "D_id,Total_person,Male_count,Female_count,caste,religion,senior_id")] table_demographic table_demographic)
        {
            if (ModelState.IsValid)
            {
                if (!db.table_demographic.Any(u => u.senior_id == table_demographic.senior_id))
                {
                    db.table_demographic.Add(table_demographic);
                    db.SaveChanges();
                    //update status value
                    var result = db.pdffiles // this explicit query is here
                                 .Where(stats => stats.demo_status == false)
                                 .Take(1);

                    foreach (var item in result)
                    {
                        ViewBag.file = item.File;
                        pdffile pdff = new pdffile();
                        using (var con = new woda_testEntities())
                        {
                            pdff             = con.pdffiles.First(x => x.File == item.File);
                            pdff.demo_status = true;

                            con.pdffiles.Attach(pdff);
                            var entry = con.Entry(pdff);
                            entry.Property(e => e.demo_status).IsModified = true;
                            con.SaveChanges();
                        }
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.error = "This Home Number already added";
                }
            }

            ViewBag.senior_id = new SelectList(db.table_house_senior_details, "senior_id", "Home_no", table_demographic.senior_id);
            return(View(table_demographic));
        }