Ejemplo n.º 1
0
 public ActionResult Autherize(ParkinglotOnline.Models.Driver driverModel, ParkinglotOnline.Models.Host hostModel)
 {
     if (driverModel.Username != null && driverModel.Password != null)
     {
         using (ParkingLotOnlineEntities db = new ParkingLotOnlineEntities())
         {
             object[] driverParam = new SqlParameter[]
             {
                 new SqlParameter("@ID", driverModel.Username),
                 new SqlParameter("@Password", driverModel.Password)
             };
             object[] hostParam = new SqlParameter[]
             {
                 new SqlParameter("@ID", driverModel.Username),
                 new SqlParameter("@Password", driverModel.Password)
             };
             var driverDetail = db.Database.SqlQuery <string>("Sp_Driver_Login @ID,@Password", driverParam).FirstOrDefault();
             var hostDetail   = db.Database.SqlQuery <string>("Sp_Host_Login @ID,@Password", hostParam).FirstOrDefault();
             var adminDetail  = db.Admins.Where(ad => ad.ID == driverModel.Username && ad.Password == driverModel.Password).FirstOrDefault();
             if (driverDetail == null && hostDetail == null && adminDetail == null)
             {
                 driverModel.LoginErrorMessage = "Invalid username or password!";
                 return(View("Index", driverModel));
             }
             else if (driverDetail != null && hostDetail == null && adminDetail == null)
             {
                 Session["driverName"] = driverDetail;
                 Session["driverID"]   = driverModel.Username;
                 if (Session["LotId"] != null && Session["HostId"] != null)
                 {
                     return(RedirectToAction("ViewHost", "Home"));
                 }
                 return(RedirectToAction("Index", "Home"));
             }
             else if (driverDetail == null && hostDetail != null && adminDetail == null)
             {
                 Session["hostID"]   = driverModel.Username;
                 Session["hostName"] = hostDetail.ToString();
                 return(RedirectToAction("List", "Host", new { area = "Host" }));
             }
             else if (driverDetail == null && hostDetail == null && adminDetail != null)
             {
                 Session["adminName"] = adminDetail.Name;
                 return(RedirectToAction("Index", "DriverManage", new { area = "Admin" }));
             }
         }
     }
     return(View("Index", driverModel));
 }
Ejemplo n.º 2
0
 public LotHostDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 3
0
 public HostRequestDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 4
0
 public BookinglotDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 5
0
 public RegisterDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
 public NumberUnAvailableDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 7
0
 public ListLotDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 8
0
 public AdminFinanceDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 9
0
 public DriverDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 10
0
 public CityDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 11
0
 public FinancialDAO()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 12
0
 public DriverManageModel()
 {
     db = new ParkingLotOnlineEntities();
 }
Ejemplo n.º 13
0
 public DetailDAO()
 {
     db = new ParkingLotOnlineEntities();
 }