Ejemplo n.º 1
0
        // POST api/<controller>
        public async Task <string> Post(LoginModel Login)
        {
            NHibernateUserStore store = new NHibernateUserStore();

            try {
                var usr = await store.FindByNamePassAsync(Login.Username, Login.Password);

                //var usr = await store.FindByIdAsync("564267a0-ac19-4811-871c-a9d9011bdfe6");
                if (usr != null)
                {
                    var session = HttpContext.Current.Session;
                    session["UserId"] = usr.Id;
                    usr = await HibernateSession.SignInUser(usr, Login.RememberMe);

                    return("Ok");
                }
                else
                {
                    return("Incorrect User or Password");
                }
#pragma warning disable CS0168 // The variable 'e' is declared but never used
            } catch (Exception e) {
#pragma warning restore CS0168 // The variable 'e' is declared but never used
                return(null);
            }
        }
Ejemplo n.º 2
0
        public async Task <UserModel> Post(LoginModel login)
        {
            NHibernateUserStore store = new NHibernateUserStore();

            var usr = await store.FindByNamePassAsync(login.Username, login.Password);

            return(usr);
        }
        // GET api/<controller>
        //public IEnumerable<string> Get() {
        //	return new string[] { "value1", "value2" };
        //}

        // GET api/<controller>/5
        public async Task <DriverProfile> Post(LoginModel Login)
        {
            NHibernateUserStore store = new NHibernateUserStore();
            var usr = await store.FindByNamePassAsync(Login.Username, Login.Password);

            if (usr.Driver != null)
            {
                string Origin = "", Destination = "", FranchiseNo = "", PlateNo = "";
                var    vehicle = (from x in usr.Driver.Vehicle.OfType <DriverVehicleModel>() where x.Status == StatusType.Active select x)
                                 .FirstOrDefault();

                if (vehicle != null)
                {
                    PlateNo     = vehicle.Vehicle.PlateNumber;
                    FranchiseNo = vehicle.Vehicle.FranchiseNo;
                    if (vehicle.Route != null)
                    {
                        Origin      = vehicle.Route.Origin;
                        Destination = vehicle.Route.Destination;
                    }
                }

                var driverProfile = new DriverProfile {
                    LastName    = usr.Driver.LastName,
                    FirstName   = usr.Driver.FirstName,
                    MiddleName  = usr.Driver.MiddleName,
                    PlateNo     = PlateNo,
                    FranchiseNo = FranchiseNo,
                    Origin      = Origin,
                    Destination = Destination,
                    Token       = usr.SecurityStamp
                };
                return(driverProfile);
            }
            return(null);
        }