Exemple #1
0
        public ActionResult Create([Bind(Include = "Add_id,Oda_no,Sabik_gabisa,Sabik_Oda,Tole,senior_id")] table_address table_address)
        {
            if (ModelState.IsValid)
            {
                if (!db.table_address.Any(u => u.senior_id == table_address.senior_id))
                {
                    //db.table_address.Any(ag => ag.senior_id == c)
                    db.table_address.Add(table_address);
                    db.SaveChanges();
                    //db.pdffiles.Add(new pdffile
                    // {
                    //   status = true

                    //});
                    // db.SaveChanges();

//for status value change from
                    var result = db.pdffiles // this explicit query is here
                                 .Where(stats => stats.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.status = true;

                            con.pdffiles.Attach(pdff);
                            var entry = con.Entry(pdff);
                            entry.Property(e => e.status).IsModified = true;
                            con.SaveChanges();
                        }
                    }


                    //to here



                    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_address.senior_id);
            return(View(table_address));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "F_id,House_type,House_area,House_total_area,roof_type,on_rent,cooking_type,entertainment,annual_income,sampannata_sthar,drinking_water,drinking_water_TYPE,fohormaila_bewasthapan,irrigation,irrigation_type,sadak_pugeko,sadak_type,bhukampa_jokhim,house_used_for,Ghar_naksha,storey,electricity,electricity_type,senior_id")] table_home_facility table_home_facility)
        {
            if (ModelState.IsValid)
            {
                if (!db.table_home_facility.Any(u => u.senior_id == table_home_facility.senior_id))
                {
                    db.table_home_facility.Add(table_home_facility);
                    db.SaveChanges();


                    //update status value
                    var result = db.pdffiles // this explicit query is here
                                 .Where(stats => stats.home_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.home_status = true;

                            con.pdffiles.Attach(pdff);
                            var entry = con.Entry(pdff);
                            entry.Property(e => e.home_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_home_facility.senior_id);
            return(View(table_home_facility));
        }
Exemple #3
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));
        }
        public ActionResult Create([Bind(Include = "senior_id,Home_no,Education,Occupation,Contact_no,DOB,BirthPlace,CitizenShip_no,CitizenshipIssue_district,citizenissue_date,Name")] table_house_senior_details table_house_senior_details)
        {
            if (ModelState.IsValid)
            {
                if (!db.table_house_senior_details.Any(u => u.Home_no == table_house_senior_details.Home_no))
                {
                    db.table_house_senior_details.Add(table_house_senior_details);
                    db.SaveChanges();

                    var result = db.pdffiles // this explicit query is here
                                 .Where(stats => stats.senior_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.senior_status = true;

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

            return(View(table_house_senior_details));
        }