/// <summary>
 /// Create a new family object.
 /// </summary>
 /// <param name="familyId">Initial value of the familyId property.</param>
 public static family Createfamily(global::System.Int32 familyId)
 {
     family family = new family();
     family.familyId = familyId;
     return family;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the families EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTofamilies(family family)
 {
     base.AddObject("families", family);
 }
 //
 // GET: /Fees/
 public ActionResult Index(family id)
 {
     if (Session["id"] == null)
         return RedirectToAction("signin", "Home");
     schooldbEntities db = new schooldbEntities();
     List<student> stdList = (from tmp in db.students where tmp.familyId == id.familyId && tmp.StudentStatus == 1 select tmp).ToList();
     List<double?> sum = (from tmp in db.students where tmp.familyId == id.familyId && tmp.StudentStatus == 1 select tmp.StudentFee).ToList();
     ViewBag.id = id.familyId;
     ViewBag.total = sum.Sum();
     return View(stdList);
 }
        public ActionResult NewFamily(family fam)
        {
            if (Session["id"] == null)
                return RedirectToAction("signin", "Home");
            DAO.families.AddObject(fam);
            DAO.SaveChanges();

            return RedirectToAction("Index");
        }
        public ActionResult Edit(int id, family fm)
        {
            if (Session["id"] == null)
                return RedirectToAction("signin", "Home");
            try
            {
                // TODO: Add update logic here
                family fami = (from fam in DAO.families where fam.familyId==id select fam).FirstOrDefault();
                fami.familyId = fm.familyId;
                fami.FatherEducation = fm.FatherEducation;
                fami.FatherIncome = fm.FatherIncome;
                fami.FatherName = fm.FatherName;
                fami.FatherNIC = fm.FatherNIC;
                fami.FatherOccupation = fm.FatherOccupation;
                fami.MotherEducation = fm.MotherEducation;
                fami.MotherIncome = fm.MotherIncome;
                fami.MotherName = fm.MotherName;
                fami.MotherNIC = fm.MotherNIC;
                fami.MotherOccupation = fm.MotherOccupation;
                fami.Religion = fm.Religion;
                fami.Nationality = fm.Nationality;
                fami.Caste = fm.Caste;

                DAO.SaveChanges();

                return RedirectToAction("ExistFamily");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Delete(int id, family fm)
        {
            if (Session["id"] == null)
                return RedirectToAction("signin", "Home");
            try
            {
                // TODO: Add delete logic here
                family fami = (from fam in DAO.families where fam.familyId == id select fam).FirstOrDefault();
                DAO.families.DeleteObject(fami);
                DAO.SaveChanges();

                return RedirectToAction("ExistFamily");
            }
            catch
            {
                return View();
            }
        }