public ActionResult ConfirmDeleteBrgyCollector(int PrimaryID)
        {
            Tbl_FMBrgy_BrgyCollector collectors = (from a in BOSSDB.Tbl_FMBrgy_BrgyCollector where a.BrgyCollectorID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMBrgy_BrgyCollector.Remove(collectors);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteBrgyCollector(int PrimaryID)
        {
            Tbl_FMBrgy_BrgyCollector collector = (from a in BOSSDB.Tbl_FMBrgy_BrgyCollector where a.BrgyCollectorID == PrimaryID select a).FirstOrDefault();
            var confirmDelete = "";

            if (collector != null)
            {
                confirmDelete = "false";
            }
            var result = new { confirmDelete = confirmDelete };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SaveBrgyCollector(BrgyCollectorModel model)
        {
            var isExist = "";

            if (ModelState.IsValid)
            {
                var fname       = model.BrangayCollectorList.Fname;
                var mname       = model.BrangayCollectorList.Mname;
                var lname       = model.BrangayCollectorList.Lname;
                var collectorid = model.BrangayCollectorList.BrgyCollectorID;

                Tbl_FMBrgy_BrgyCollector checkcollector = (from a in BOSSDB.Tbl_FMBrgy_BrgyCollector where (a.Fname == fname && a.Mname == mname && a.Lname == lname) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkcollector == null)
                    {
                        Tbl_FMBrgy_BrgyCollector brgyCollect = new Tbl_FMBrgy_BrgyCollector();
                        brgyCollect.Fname = fname;
                        brgyCollect.Mname = mname;
                        brgyCollect.Lname = lname;
                        BOSSDB.Tbl_FMBrgy_BrgyCollector.Add(brgyCollect);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkcollector != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMBrgy_BrgyCollector        collectii  = (from a in BOSSDB.Tbl_FMBrgy_BrgyCollector where a.BrgyCollectorID == collectorid select a).FirstOrDefault();
                    List <Tbl_FMBrgy_BrgyCollector> fnameCount = (from e in BOSSDB.Tbl_FMBrgy_BrgyCollector where e.Fname == fname select e).ToList();
                    List <Tbl_FMBrgy_BrgyCollector> lnameCount = (from e in BOSSDB.Tbl_FMBrgy_BrgyCollector where e.Lname == lname select e).ToList();
                    List <Tbl_FMBrgy_BrgyCollector> mnameCount = (from e in BOSSDB.Tbl_FMBrgy_BrgyCollector where e.Mname == mname select e).ToList();
                    if (checkcollector != null)
                    {
                        if (mname != null)
                        {
                            if (collectii.Fname != fname && fnameCount.Count >= 1 && collectii.Lname != lname && lnameCount.Count >= 1 && collectii.Mname != mname)
                            {
                                isExist = "true";
                            }
                            else
                            {
                                isExist = "justUpdate";
                            }
                        }
                        else
                        {
                            if (collectii.Fname != fname && fnameCount.Count >= 1 && collectii.Lname != lname && lnameCount.Count >= 1)
                            {
                                isExist = "true";
                            }
                            else
                            {
                                isExist = "justUpdate";
                            }
                        }
                    }
                    else if (checkcollector == null)
                    {
                        isExist = "justUpdate";
                    }

                    if (isExist == "justUpdate")
                    {
                        collectii.Fname = fname;
                        collectii.Mname = mname;
                        collectii.Lname = lname;
                        BOSSDB.Entry(collectii);
                        BOSSDB.SaveChanges();
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }