示例#1
0
 public ActionResult Create(Fund fund)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //fundRepository.InsertFund(fund);
             NHibernateHelper helper = new NHibernateHelper("thangma");
             // Notice the unit of work we are using is to commit
             //    one truck's data at a time.
             UnitOfWork unitOfWork = new UnitOfWork(helper.SessionFactory);
             Repository<Fund> repository = new Repository<Fund>(unitOfWork.Session);
             //Truck truck = CreateFund();
             repository.Add(fund);
             unitOfWork.Commit();
             return RedirectToAction("Index");
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException)
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(fund);
 }
示例#2
0
 //public FundController(IFundRepository fundRepository)
 //{
 //    //this._fundRepository = fundRepository;
 //}//
 // GET: /Fund/
 public ActionResult Index(string returnUrl)
 {
     //var persons = fundRepository.GetFunds();
     //return View(persons);
     //fundRepository.InsertFund(fund);
     NHibernateHelper helper = new NHibernateHelper("thangma");
     // Notice the unit of work we are using is to commit
     //    one truck's data at a time.
     UnitOfWork unitOfWork = new UnitOfWork(helper.SessionFactory);
     Repository<Fund> repository = new Repository<Fund>(unitOfWork.Session);
     var funds = repository.All();
     //Truck truck = CreateFund();
     return View(funds);
 }