示例#1
0
 ///Local Method
 private void CreateTravelStudentData(TravelStudent ts, Student student, TravelStatus status)
 {
     ts.StartAt = DateTime.UtcNow.ToLocalTime();
     ts.Student = student;
     ts.Status  = status;
     _context.TravelsStudent.Add(ts);
 }
示例#2
0
        public async Task SetTravelStatus(string userId, string itemId, TravelStatus travelStatus)
        {
            var item = await digitServiceContext.FocusItems
                       .Include(f => f.Directions)
                       .Where(v => v.Id == itemId).SingleAsync();

            if (null != item.Directions)
            {
                item.Directions.TravelStatus = travelStatus;
            }
            await digitServiceContext.SaveChangesAsync();
        }
示例#3
0
        public IActionResult UpdateTravelStatus(Guid studentID, int travelStatus)
        {
            var student = _context.Students.FirstOrDefault(s => s.Id == studentID);

            if (student.NeedTravel)
            {
                if (student == null)
                {
                    return(NotFound());
                }

                var           status = new TravelStatus();
                TravelStudent ts     = new TravelStudent();

                switch (travelStatus)
                {
                case 70:
                    status = TravelStatus.AtScholl;
                    CreateTravelStudentData(ts, student, status);
                    break;

                case 75:
                    status = TravelStatus.AtHome;
                    CreateTravelStudentData(ts, student, status);
                    break;

                case 80:
                    status = TravelStatus.Trasnporting;
                    CreateTravelStudentData(ts, student, status);
                    break;

                case 85:
                    status = TravelStatus.IsComing;
                    CreateTravelStudentData(ts, student, status);
                    break;
                }

                var result = _context.SaveChanges();

                if (result == 0)
                {
                    return(BadRequest());
                }

                return(Ok());
            }
            else
            {
                return(NotFound("Aluno não precisa"));
            }
        }
示例#4
0
 public string TravelInfo()
 {
     return(TravelStatus.ToString("TT: "));
 }
示例#5
0
        /// <summary>
        /// Move the fleet towards the waypoint at the top of the list. Fuel is consumed
        /// at the rate of the sum of each of the individual ships (i.e. available fuel
        /// is automatically "pooled" between the ships).
        /// </summary>
        /// <param name="availableTime">The portion of a year left for travel.</param>
        /// <param name="race">The race this fleet belongs to.</param>
        /// <returns>A TravelStatus indicating arrival or in-transit.</returns>
        public TravelStatus Move(ref double availableTime, Race race)
        {
            if (GetTravelStatus() == TravelStatus.Arrived)
            {
                return(TravelStatus.Arrived);
            }

            Waypoint target = Waypoints[0];

            InOrbit = null;

            double legDistance = PointUtilities.Distance(Position, target.Position);

            int    warpFactor          = target.WarpFactor;
            int    speed               = warpFactor * warpFactor;
            double targetTime          = legDistance / speed;
            double fuelConsumptionRate = FuelConsumption(warpFactor, race);
            double fuelTime            = FuelAvailable / fuelConsumptionRate;
            double travelTime          = targetTime;

            // Determine just how long we have available to travel towards the
            // waypoint target. This will be the smaller of target time (the ideal
            // case, we get there) available time (didn't get there but still can
            // move towards there next turn) and fuel time.

            TravelStatus arrived = TravelStatus.Arrived;

            if (travelTime > availableTime)
            {
                travelTime = availableTime;
                arrived    = TravelStatus.InTransit;
            }

            if (travelTime >= fuelTime)
            {
                travelTime = fuelTime;
                arrived    = TravelStatus.InTransit;
            }

            // If we have arrived then the new fleet position is the waypoint
            // target. Otherwise the position is determined by how far we got
            // in the time or fuel available.

            if (arrived == TravelStatus.Arrived)
            {
                Position          = target.Position;
                target.WarpFactor = 0;
            }
            else
            {
                double travelled = speed * travelTime;
                Position = PointUtilities.MoveTo(Position, target.Position, travelled);
            }

            // Update the travel time left for this year and the total fuel we
            // now have available.

            availableTime -= travelTime;
            int fuelUsed = (int)(fuelConsumptionRate * travelTime);

            FuelAvailable -= fuelUsed;

            // Added check if fleet run out of full it's speed will be changed
            // to free warp speed.
            if (arrived == TravelStatus.InTransit && fuelConsumptionRate > this.FuelAvailable)
            {
                target.WarpFactor = this.FreeWarpSpeed;
            }
            return(arrived);
        }
示例#6
0
 public string TravelInfo()
 {
     return(TravelStatus.ToString(StopMarker ? "Travelled" : "Travelling "));
 }