public ActionResult DeleteAppropSource(int AppropriationID)
        {
            Tbl_FMApprop_AppropriationSource ASource = (from a in BOSSDB.Tbl_FMApprop_AppropriationSource where a.AppropriationID == AppropriationID select a).FirstOrDefault();

            BOSSDB.Tbl_FMApprop_AppropriationSource.Remove(ASource);
            BOSSDB.SaveChanges();

            var result = "";

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

            if (ModelState.IsValid)
            {
                var appropDesc = model.AppropSourceList.Description;
                appropDesc = Regex.Replace(appropDesc, @"\s\s+", "");
                appropDesc = Regex.Replace(appropDesc, @"^\s+", "");
                appropDesc = Regex.Replace(appropDesc, @"\s+$", "");
                appropDesc = new CultureInfo("en-US").TextInfo.ToTitleCase(appropDesc);
                Tbl_FMApprop_AppropriationSource checkApprop = (from a in BOSSDB.Tbl_FMApprop_AppropriationSource where (a.Description == model.AppropSourceList.Description) select a).FirstOrDefault();

                if (model.ActionID == 1)
                {
                    if (checkApprop == null)
                    {
                        Tbl_FMApprop_AppropriationSource appropS = new Tbl_FMApprop_AppropriationSource();
                        appropS.Description  = appropDesc;
                        appropS.FundSourceID = model.FundSourceID;
                        appropS.BudgetYearID = model.BudgetYearID;
                        BOSSDB.Tbl_FMApprop_AppropriationSource.Add(appropS);
                        BOSSDB.SaveChanges();
                        isExist = "false";
                    }
                    else if (checkApprop != null)
                    {
                        isExist = "true";
                    }
                }
                else if (model.ActionID == 2)
                {
                    Tbl_FMApprop_AppropriationSource        approp            = (from a in BOSSDB.Tbl_FMApprop_AppropriationSource where a.AppropriationID == model.AppropSourceList.AppropriationID select a).FirstOrDefault();
                    List <Tbl_FMApprop_AppropriationSource> appropDescription = (from e in BOSSDB.Tbl_FMApprop_AppropriationSource where e.Description == appropDesc select e).ToList();
                    if (checkApprop != null)
                    {
                        if (approp.Description == appropDesc)
                        {
                            isExist = "justUpdate";
                        }
                        else
                        {
                            if (approp.Description != appropDesc && appropDescription.Count >= 1)
                            {
                                isExist = "true";
                            }
                            else
                            {
                                isExist = "justUpdate";
                            }
                        }
                    }
                    else if (checkApprop == null)
                    {
                        isExist = "justUpdate";
                    }
                    if (isExist == "justUpdate")
                    {
                        approp.Description  = appropDesc;
                        approp.FundSourceID = model.FundSourceID;
                        approp.BudgetYearID = model.BudgetYearID;
                        BOSSDB.Entry(approp);
                        BOSSDB.SaveChanges();
                    }
                }
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { isExist = isExist }
            });
        }