public ActionResult SaveBrgyName(BrgyNameModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var brgyname = model.BarangayNameList.BrgyName;

                Tbl_FMBrgy_Barangay checkbrgy = (from a in BOSSDB.Tbl_FMBrgy_Barangay where (a.BrgyName == brgyname) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkbrgy == null)
                    {
                        Tbl_FMBrgy_Barangay brgy = new Tbl_FMBrgy_Barangay();
                        brgy.BrgyName = brgyname;
                        BOSSDB.Tbl_FMBrgy_Barangay.Add(brgy);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkbrgy != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMBrgy_Barangay        bgryii    = (from a in BOSSDB.Tbl_FMBrgy_Barangay where a.BrgyID == model.BarangayNameList.BrgyID select a).FirstOrDefault();
                    List <Tbl_FMBrgy_Barangay> brgyCount = (from e in BOSSDB.Tbl_FMBrgy_Barangay where e.BrgyName == brgyname select e).ToList();
                    if (checkbrgy != null)
                    {
                        if (bgryii.BrgyName != brgyname && brgyCount.Count >= 1)
                        {
                            isExist = "true";
                        }
                        else
                        {
                            isExist = "justUpdate";
                        }
                    }
                    else if (checkbrgy == null)
                    {
                        isExist = "justUpdate";
                    }

                    if (isExist == "justUpdate")
                    {
                        bgryii.BrgyName = brgyname;
                        BOSSDB.Entry(bgryii);
                        BOSSDB.SaveChanges();
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }
        public ActionResult ConfirmDeleteBrgyName(int PrimaryID)
        {
            Tbl_FMBrgy_Barangay brgyss = (from a in BOSSDB.Tbl_FMBrgy_Barangay where a.BrgyID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMBrgy_Barangay.Remove(brgyss);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteBrgyName(int PrimaryID)
        {
            Tbl_FMBrgy_Barangay        brgys         = (from a in BOSSDB.Tbl_FMBrgy_Barangay where a.BrgyID == PrimaryID select a).FirstOrDefault();
            Tbl_FMBrgy_BrgyBankAccount BrgyBankaccnt = (from a in BOSSDB.Tbl_FMBrgy_BrgyBankAccount where a.BrgyID == PrimaryID select a).FirstOrDefault();
            var confirmDelete = "";

            if (brgys != null)
            {
                if (BrgyBankaccnt != null)
                {
                    confirmDelete = "true";
                }
                else
                {
                    confirmDelete = "false";
                }
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }