public ActionResult ConfirmDelete(int PrimaryID)
        {
            Tbl_FMApprop_FundSource fundSource = (from a in BOSSDB.Tbl_FMApprop_FundSource where a.FundSourceID == PrimaryID select a).FirstOrDefault();

            BOSSDB.Tbl_FMApprop_FundSource.Remove(fundSource);
            BOSSDB.SaveChanges();

            var result = "";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DeleteFundSource(int PrimaryID)
        {
            Tbl_FMApprop_FundSource fSource = (from a in BOSSDB.Tbl_FMApprop_FundSource where a.FundSourceID == PrimaryID select a).FirstOrDefault();

            var confirmDelete = "";

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

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

            if (ModelState.IsValid)
            {
                var fundsourceTitle = model.FundSourceList.FundSourceTitle;
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"\s\s+", "");
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"^\s+", "");
                fundsourceTitle = Regex.Replace(fundsourceTitle, @"\s+$", "");
                fundsourceTitle = new CultureInfo("en-US").TextInfo.ToTitleCase(fundsourceTitle);
                Tbl_FMApprop_FundSource checkFundsource = (from a in BOSSDB.Tbl_FMApprop_FundSource where (a.FundSourceTitle == fundsourceTitle) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkFundsource == null)
                    {
                        Tbl_FMApprop_FundSource fundsource = new Tbl_FMApprop_FundSource();
                        fundsource.FundSourceTitle    = fundsourceTitle;
                        fundsource.AppropSourceTypeID = model.AppropSourceTypeID;
                        BOSSDB.Tbl_FMApprop_FundSource.Add(fundsource);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkFundsource != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMApprop_FundSource        fundS           = (from a in BOSSDB.Tbl_FMApprop_FundSource where a.FundSourceID == model.FundSourceList.FundSourceID select a).FirstOrDefault();
                    List <Tbl_FMApprop_FundSource> fundsourcetitle = (from e in BOSSDB.Tbl_FMApprop_FundSource where e.FundSourceTitle == fundsourceTitle select e).ToList();
                    if (checkFundsource != null)
                    {
                        if (fundS.FundSourceTitle != fundsourceTitle && fundsourcetitle.Count >= 1)
                        {
                            isExist = "true";
                        }
                        else
                        {
                            fundS.FundSourceTitle    = fundsourceTitle;
                            fundS.AppropSourceTypeID = model.AppropSourceTypeID;
                            BOSSDB.Entry(fundS);
                            BOSSDB.SaveChanges();
                            isExist = "justUpdate";
                        }
                    }
                    else if (checkFundsource == null)
                    {
                        fundS.FundSourceTitle    = fundsourceTitle;
                        fundS.AppropSourceTypeID = model.AppropSourceTypeID;
                        BOSSDB.Entry(fundS);
                        BOSSDB.SaveChanges();
                        isExist = "justUpdate";
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }