Inheritance: System.Web.UI.Page
        // 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);
        }
Exemplo n.º 2
0
        // POST api/values
        public void Post([FromBody] Flag [] flags)
        {
            var collection = MongoHelper.Current.Database.GetCollection <DriverPosition>("driverpositions");
            var customerId = flags[0].CustomerId;

            foreach (var item in flags)
            {
                var driverPosition = new DriverPosition
                {
                    DriverId         = item.CustomerId,
                    Latitude         = item.Position.Coordinates.Latitude,
                    Longitude        = item.Position.Coordinates.Longtitude,
                    Altitude         = item.Altitude,
                    AltitudeAccuracy = item.AltitudeAccuracy,
                    TimeStamp        = item.Time,
                    Heading          = item.Heading,
                    ////Type = item.Type,
                };
                collection.Insert(driverPosition);
            }
            var profile = new DriverProfile();

            profile.HandleData(customerId);
        }