Esempio n. 1
0
 public ActionResult Create(string fundid)
 {
     var id = fundid.ToInt();
     if (id == 0)
         return Json(new { error = "expected an integer (account number)" });
     var f = DbUtil.Db.ContributionFunds.SingleOrDefault(ff => ff.FundId == id);
     if (f != null)
         return Json(new { error = "fund already exists: {0} ({1})".Fmt(f.FundName, fundid) });
     try
     {
         f = new ContributionFund
         {
             FundName = "new fund",
             FundId=id,
             CreatedBy = Util.UserId1,
             CreatedDate = Util.Now,
             FundStatusId = 1,
             FundTypeId = 1,
             FundPledgeFlag = false,
             NonTaxDeductible = false
         };
         DbUtil.Db.ContributionFunds.InsertOnSubmit(f);
         DbUtil.Db.SubmitChanges();
         return Json(new {edit = "/Finance/Fund/Edit/" + id});
     }
     catch(Exception ex)
     {
         return Json(new {error = ex.Message});
     }
 }
Esempio n. 2
0
        public ContributionFund FetchOrCreateFund(int FundId, string Description)
        {
            ContributionFund fund;

            if (FundId > 0)
            {
                fund = ContributionFunds.SingleOrDefault(f => f.FundId == FundId);
            }
            else
            {
                fund = ContributionFunds.FirstOrDefault(f => f.FundName == Description && f.FundStatusId == 1);
            }
            if (fund == null)
            {
                int nextfundid;
                if (FundId > 0)
                {
                    nextfundid = FundId;
                }
                else
                {
                    nextfundid = ContributionFunds.Max(ff => ff.FundId) + 1;
                }
                fund = new ContributionFund
                {
                    FundName       = Description,
                    FundId         = nextfundid,
                    CreatedBy      = 1,
                    CreatedDate    = DateTime.Now,
                    FundStatusId   = 1,
                    FundTypeId     = 1,
                    FundPledgeFlag = false,
                };
                ContributionFunds.InsertOnSubmit(fund);
                SubmitChanges();
            }
            return(fund);
        }