示例#1
0
 public ActionResult Create(Land l, int LandStatusId)
 {
     try
     {
         using (db)
         {
             l.LandStatusId = LandStatusId;
             l.AdminId      = Convert.ToInt32(Session["aid"]);
             l.CreateDate   = DateTime.Now;
             db.Lands.Add(l);
             db.SaveChanges();
         }
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException e)
     {
         Exception raise = e;
         foreach (var validationErrors in e.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
         //TempData["message"] = "Something is wrong! " + e;
     }
     return(RedirectToAction("List"));
 }
示例#2
0
 public ActionResult Create(Payment p)
 {
     using (db)
     {
         db.Payments.Add(p);
         db.SaveChanges();
     }
     return(RedirectToAction("List"));
 }
示例#3
0
 public ActionResult Create(Room r)
 {
     using (db)
     {
         db.Rooms.Add(r);
         db.SaveChanges();
     }
     return(RedirectToAction("List"));
 }
示例#4
0
 public ActionResult Create(Floor f)
 {
     using (db)
     {
         db.Floors.Add(f);
         db.SaveChanges();
     }
     return(RedirectToAction("List"));
 }
示例#5
0
 public ActionResult Create(Sale s)
 {
     using (db)
     {
         //s.Date = DateTime.Now;
         db.Sales.Add(s);
         db.SaveChanges();
     }
     return(RedirectToAction("List"));
 }
示例#6
0
 public ActionResult Create(Building b, int BuildingStatusId, int BuildTypeId)
 {
     using (db)
     {
         b.BuildingStatusId = BuildingStatusId;
         b.BuildTypeId      = BuildTypeId;
         db.Buildings.Add(b);
         db.SaveChanges();
     }
     return(RedirectToAction("List"));
 }