public ActionResult Create(MultipleAdmin model) { try { if (!ModelState.IsValid) { string LotID = Request.Form["SLRange"]; LotHostDAO dao = new LotHostDAO(); int result = dao.Create(model.LotHostInsert.LoHID, model.LotHostInsert.HostID, LotID); if (result > 0) { Session["SUCCESS"] = "Create Parking Lot"; return(RedirectToAction("Create", "AdminCreateParkingLot", new { area = "Admin" })); } } Session["SUCCESS"] = null; model.ErrorAcceptMessage = "Can't create new parking lot!"; model.Lot = new LotHostDAO().ListLot(); return(View(model)); } catch { Session["SUCCESS"] = null; model.ErrorAcceptMessage = "Host ID is not existed or LoHID is existed!"; model.Lot = new LotHostDAO().ListLot(); return(View(model)); } }
public ActionResult Create(MultipleCreatePage model) { try { // TODO: Add insert logic here if (ModelState.IsValid) { LotHostDAO dao = new LotHostDAO(); int count = dao.CountLotHot(Session["hostID"].ToString()); string LoHID = Session["hostID"].ToString().ToUpper() + "-" + count; int result = dao.Create(LoHID, Session["hostID"].ToString(), model.LotHostInsert.LotID); if (result > 0) { Session["SUCCESS"] = "Create Parking Lot " + LoHID + " Success!\n Waiting For Administration Accept!"; return(RedirectToAction("Create", "CreateParkingLot", new { area = "Host" })); } else { ModelState.AddModelError("", "Create new parking lot is false!"); } } Session["SUCCESS"] = null; List <Lot> lists = new LotDAO().ListLot(); model.ListLot = lists; return(View(model)); } catch { Session["SUCCESS"] = null; List <Lot> lists = new LotDAO().ListLot(); model.ListLot = lists; model.CreateErrorMessage = "You must select range of parking lot!"; return(View(model)); } }