Exemple #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);
 }
Exemple #2
0
 private static Fund CreateFund(string fundName)
 {
     Fund fund = new Fund
     {
         FundName = fundName
     };
     return fund;
 }