public static TruckAnimation FindNext( Travel.Extremity from, Travel.Extremity to) { switch (from) { case Travel.Extremity.Top: switch (to) { case Travel.Extremity.Bottom: return TruckAnimation.Top2Bottom; case Travel.Extremity.Left: return TruckAnimation.Top2Left; case Travel.Extremity.Right: return TruckAnimation.Top2Right; default: throw new ArgumentException("Can't move from top to top"); } case Travel.Extremity.Bottom: switch (to) { case Travel.Extremity.Top: return TruckAnimation.Bottom2Top; case Travel.Extremity.Left: return TruckAnimation.Bottom2Left; case Travel.Extremity.Right: return TruckAnimation.Bottom2Right; default: throw new ArgumentException("Can't move from bottom to bottom"); } case Travel.Extremity.Left: switch (to) { case Travel.Extremity.Top: return TruckAnimation.Left2Top; case Travel.Extremity.Right: return TruckAnimation.Left2Right; case Travel.Extremity.Bottom: return TruckAnimation.Left2Bottom; default: throw new ArgumentException("Can't move from left to left"); } case Travel.Extremity.Right: switch (to) { case Travel.Extremity.Top: return TruckAnimation.Right2Top; case Travel.Extremity.Left: return TruckAnimation.Right2Left; case Travel.Extremity.Bottom: return TruckAnimation.Right2Bottom; default: throw new ArgumentException("Can't move from right to right"); } default: throw new ArgumentException("Impossible case: " + from); } }
public static List<Travel> FindTravel(string name, Dictionary<string, List<Travel>> travelDictionary) { List<Travel> possibleTravels = new List<Travel>(); Travel target = new Travel(CleanName(name)); if (travelDictionary.ContainsKey(target.Key)) { return travelDictionary[target.Key]; } return null; }
public ActionResult DeleteConfirmed(int id) { Travel b = db.Travels.Find(id); if (b == null) { return(HttpNotFound()); } db.Travels.Remove(b); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,StartFrom,EndTo,TravelTypeID,guiderID")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.guiderID = new SelectList(db.Guides, "ID", "firstName", travel.guiderID); ViewBag.TravelTypeID = new SelectList(db.TravelTypes, "TravelTypeID", "Name", travel.TravelTypeID); return(View(travel)); }
public ActionResult Edit([Bind(Include = "TravelId,Name,DirectionId,CarId,TravelDate")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarId = new SelectList(db.Cars, "CarId", "Name", travel.CarId); ViewBag.DirectionId = new SelectList(db.Directions, "DirectionId", "Name", travel.DirectionId); return(View(travel)); }
public bool Insert(Travel travel) { int autonumber = 0; TravelDAC travelComponent = new TravelDAC(); bool endedSuccessfuly = travelComponent.InsertNewTravel(ref autonumber, travel.Name, travel.TransportationTypeID, travel.Description, travel.ConferenceID); if (endedSuccessfuly) { travel.ID = autonumber; } return(endedSuccessfuly); }
public ActionResult Edit([Bind(Include = "ID,DateGo,DateBack,SpaceAvailable,Price,TravelAgencyID,DestinationID")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DestinationID = new SelectList(db.Destinations, "ID", "Area", travel.DestinationID); ViewBag.TravelAgencyID = new SelectList(db.TravelAgencys, "ID", "Name", travel.TravelAgencyID); return(View(travel)); }
public void Travel_Should_Be_Cancelled() { //arrange Travel travel = new Travel(new TravelId(), "Lodz"); Customer customer = new Customer("John", "Smith"); //act travel.Cancel(); //assert Assert.True(travel.IsCancel); }
public async void CreateTravel(string name) { var createdAt = DateTime.Now; var sharingCode = GetHashString(createdAt.ToString()); Models.DataContext context = new Models.DataContext(); var tmp = await context.Travel.AddAsync(new Travel { SharingCode = sharingCode, CreatedAt = createdAt, Name = name }); _travel = tmp.Entity; await context.SaveChangesAsync(); }
public void Travel_Should_Be_Editted() { //arrange Travel travel = new Travel(new TravelId(), "Lodz"); Travel travelEdited = new Travel(new TravelId(), "Warsaw"); //act travel.Edit(travelEdited); //assert Assert.Equal("Warsaw", travel.Destination); }
public void AddTravelSuccessfully() { Travel travel = new Travel( "Name", new DateTime(2019, 3, 10, 0, 0, 0), new DateTime(2019, 4, 10, 0, 0, 0), "Description", 5 ); Assert.NotZero(TravelRepository.AddTravel(travel)); }
public static void DeleteTravel(Travel oldTravel, List<Travel> travelList, Dictionary<string, List<Travel>> travelDictionary) { travelList.Remove(oldTravel); travelDictionary[oldTravel.Key].Remove(oldTravel); if(!travelDictionary[oldTravel.Key].Any()) { travelDictionary.Remove(oldTravel.Key); } UpdateTextFile(fileName, travelList, false); }
public void Test_route_GRU_to_ORL() { var travel = new Travel(_routes); travel.GetBestRoute("GRU", "ORL"); var result = travel.PossibleRoutes.Any(x => x.Route == "GRU-ORL") && travel.PossibleRoutes.Any(x => x.Route == "GRU-SCL-ORL") && travel.PossibleRoutes.Any(x => x.Route == "GRU-BRC-SCL-ORL"); Assert.IsTrue(result); }
public ActionResult Edit([Bind(Include = "ID,DepartureDate,ReturnDate,AvailablePlaces,AllInclusivePrice,TravelAgencyID,DestinationID")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DestinationID = new SelectList(db.Destinations, "ID", "Continent", travel.DestinationID); ViewBag.TravelAgencyID = new SelectList(db.TravelAgencies, "ID", "Name", travel.TravelAgencyID); return(View(travel)); }
public void Test_Address_Email() { //arrange Travel traveller = new Travel("Harry Buffalo"); //action traveller.Email = " "; string response = traveller.Email; //assert Assert.That(response, Is.EqualTo(" ")); }
public IHttpActionResult PostTravel(Travel travel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Travels.Add(travel); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = travel.Id }, travel)); }
public static async Task <bool> KillVaal() { if (_vaalKilled) { // tp to town to skip lengthy transition opening if (World.Act2.ForestEncampment.IsCurrentArea) { return(false); } await Travel.To(World.Act2.ForestEncampment); return(true); } if (World.Act2.AncientPyramid.IsCurrentArea) { var darkAltar = DarkAltar; if (darkAltar != null) { if (await Helpers.StopBeforeBoss(Settings.BossNames.VaalOversoul)) { return(true); } if (!darkAltar.IsOpened) { await darkAltar.WalkablePosition().ComeAtOnce(); if (!await PlayerAction.Interact(darkAltar, () => darkAltar.Fresh().IsOpened, "Dark Altar opening")) { ErrorManager.ReportError(); } return(true); } var vaal = VaalOversoul; if (vaal != null) { await Helpers.MoveToBossOrAnyMob(vaal); return(true); } await Helpers.MoveAndWait(darkAltar.WalkablePosition(), "Waiting for Vaal Oversoul"); return(true); } } await Travel.To(World.Act3.CityOfSarn); return(true); }
public void AddTravel([FromBody] TravelDTO travelDTO) { Travel travel = new Travel { UserId = travelDTO.UserId, CityId = dbcontext.Cities.Where(c => c.Name == travelDTO.CityName).Select(c => c.Id).First(), PriceType = travelDTO.PriceType, PeopleAmount = travelDTO.PeopleAmount }; dbcontext.Add(travel); dbcontext.SaveChanges(); }
public void AddTravel_RequiredAttributeException_WithoutDatetime() { Travel travel = new Travel( "", DateTime.MinValue, new DateTime(2019, 4, 10, 0, 0, 0), "Description", 5 ); Assert.Throws <RequiredAttributeException>( () => TravelRepository.AddTravel(travel)); }
public void AddTravel_UserNotFoundException() { Travel travel = new Travel( "Name", new DateTime(2019, 3, 10, 0, 0, 0), new DateTime(2019, 4, 10, 0, 0, 0), "Description", 200 ); Assert.Throws <UserNotFoundException>( () => TravelRepository.AddTravel(travel)); }
public static Travel Convertion(TravelsDTO travel) { Travel newTravel = new Travel(); newTravel.id = travel.id; newTravel.bas = travel.buss; newTravel.price = travel.price; newTravel.areaID = travel.areaID; // newTravel.InternalOrIntermediate = travel.internalOrIntermediate; newTravel.travelTrip = travel.trvelTrip; newTravel.date = travel.date; return(newTravel); }
public void Init() { inst = this; var start = transform.localPosition; var end = start + new Vector3(0, -CamCtrl.HEIGHT); travelIn = new Travel(transform, end, start, Easing.QuadEaseIn); travelOut = new Travel(transform, start, end, Easing.QuadEaseOut); travelIn.SetDelta(0); requestQueue = new Queue <DialogRequest>(); open = false; animElapsed = 0; }
public async Task <IActionResult> Create([Bind("OutboundFlightId,CustomerId,OutboundDate,OneWay,ReturnFlightId,ReturnDate")] Travel travel) { if (ModelState.IsValid) { travel.OutboundFlightId = Guid.NewGuid(); _context.Add(travel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerId", travel.CustomerId); return(View(travel)); }
public ActionResult Edit(Travel travel) //Edit([Bind(Include = "Id,TypeTravel")] Travel travel) { TravelOrganiser t = travel.TravelOrganiser; if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.Entry(travel.TravelOrganiser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(travel)); }
void view_OnCreateNewTravel(object sender, NameDetailsEventArgs e) { travel = new Travel() { Name = e.Name, Details = e.Details }; view.BindTravel(travel); paymentsEngine = new PaymentsEngine(travel); claimEngine = new ClaimEngine(travel); }
public static void AbandonCurrentArea() { var botName = BotManager.Current.Name; if (botName.Contains("QuestBot")) { Travel.RequestNewInstance(World.CurrentArea); } else if (botName.Contains("MapBot")) { BotManager.Current.Message(new Message("MB_set_is_on_run", null, false)); } }
public void Create(Travel travel) { try { VerifyIsValidSchedule(travel); ValidateIsAvailableSchedule(travel.Schedule); CrudFactory.Create(travel); } catch (Exception bex) { ExceptionManager.GetInstance().Process(bex); } }
public void FirstAndLast() { Travel <int> t = MakeTravel; Assert.That(t.FirstEvent.Time, Is.Zero); Assert.That(t.FirstEvent.Position, Is.Zero); Assert.That(t.FirstData, Is.EqualTo(500)); Assert.That(t.LastEvent.Time, Is.EqualTo(15)); Assert.That(t.LastEvent.Position, Is.EqualTo(40)); Assert.That(t.LastData, Is.EqualTo(800)); t.Dispose(); }
public Travel QueryTravelItemTest(string partitionKey, Guid rowKey, bool allowNull = false) { TravelModelContainer ctx = new TravelModelContainer(); var query = from t in ctx.Travels where t.PartitionKey == partitionKey && t.RowKey == rowKey select t; Travel travelView = query.FirstOrDefault(); if (!allowNull) { Assert.IsNotNull(travelView); } ctx.Dispose(); return(travelView); }
public void Move(ActionRequest response, object target) { var travel = new Travel(); response.Meeple.DayAction = travel; response.Player.Location.NextLocation = target as Location; var distance = response.Player.Location.DistanceToTravel; for (var i = 0; i < distance; i++) { travel.AddEvent(response.Player.Game.Events.NextEvent); } }
public async Task <Travel> CreateNewTravel(Travel travel) { try { var res = await _repository.CreateNewTravel(travel); return(res); } catch (Exception ex) { throw ex; } }
public async Task <string> UpdateTravel(int id, Travel travel) { try { var res = await _repository.UpdateTravel(id, travel); return(res); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新集合. /// </summary> public object ResetResource(object resource) { if (resource is Travel) { Travel updated = (Travel)resource; var original = this._entityFrameworkContext.Travels.Where( t => t.PartitionKey == updated.PartitionKey && t.RowKey == updated.RowKey).FirstOrDefault(); original.GeoLocationText = updated.GeoLocationText; original.Place = updated.Place; original.Time = updated.Time; } return(resource); }
public static void AddTravel(Travel newTravel, List<Travel> travelList, Dictionary<string, List<Travel>> travelDictionary) { if(!string.IsNullOrEmpty(newTravel.Name)) { if (!travelList.Contains(newTravel)) { travelList.Add(newTravel); } if (travelDictionary.ContainsKey(newTravel.Key)) { if (!travelDictionary[newTravel.Key].Contains(newTravel)) { travelDictionary[newTravel.Key].Add(newTravel); } } else { List<Travel> newTravelList = new List<Travel>(); newTravelList.Add(newTravel); travelDictionary.Add(newTravel.Key, newTravelList); } } }
public static void Travel() { Console.WriteLine("Problem A"); var sw = new Stopwatch(); sw.Start(); using (var p = new Travel()) { p.Solve("A-small-practice"); } sw.Stop(); Console.WriteLine(sw.Elapsed); sw.Reset(); sw.Start(); using (var p = new Travel()) { p.Solve("A-large-practice"); } sw.Stop(); Console.WriteLine(sw.Elapsed); }
public static TruckAnimation FindNextFrom( IMapTile ModelTile, Travel.Extremity from) { if (ModelTile is IRoadTile) { IRoadTile Road = (IRoadTile)ModelTile; switch (Road.Type) { case RoadTile.RoadType.BottomLeft: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Bottom; } else { return TruckAnimation.Bottom2Left; } case RoadTile.RoadType.BottomRight: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Bottom; } else { return TruckAnimation.Bottom2Right; } case RoadTile.RoadType.Horizontal: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Left; } else { return TruckAnimation.Left2Right; } case RoadTile.RoadType.TopLeft: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Left; } else { return TruckAnimation.Left2Top; } case RoadTile.RoadType.TopRight: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Right; } else { return TruckAnimation.Right2Top; } case RoadTile.RoadType.Vertical: if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomLeft: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Bottom; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomRight: if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Bottom; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } case RoadTile.RoadType.TopBottomLeftRight: if (from == Travel.Extremity.Left) { return TruckAnimation.Left2Right; } else if (from == Travel.Extremity.Right) { return TruckAnimation.Right2Left; } else if (from == Travel.Extremity.Top) { return TruckAnimation.Top2Bottom; } else { return TruckAnimation.Bottom2Top; } default: return TruckAnimation.Missing; } } else { throw new ArgumentException("Can't animate the truck somewhere else than on a road"); } }
public static void UpdateTextFile(string fileName, Travel newTravel) { List<Travel> temp = new List<Travel>(); temp.Add(newTravel); UpdateTextFile(fileName, temp , true); }
public void AddToTravels(Travel travel) { base.AddObject("Travels", travel); }
public static Travel CreateTravel(string partitionKey, global::System.Guid rowKey, global::System.DateTime time, double latitude, double longitude) { Travel travel = new Travel(); travel.PartitionKey = partitionKey; travel.RowKey = rowKey; travel.Time = time; travel.Latitude = latitude; travel.Longitude = longitude; return travel; }
private void travelListbox_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.Label != null) { Travel old = new Travel(travelListbox.Items[e.Item].Text); string newName = e.Label; Util.EditTravel(old, newName, travelList, travelDictionary); } }
private void deleteButton_Click(object sender, EventArgs e) { using (new CenterWinDialog(this)) { DialogResult result = MessageBox.Show( "Are you sure you want to delete?", "Confirmation", MessageBoxButtons.YesNo); if (result == DialogResult.Yes && travelListbox.SelectedItems.Count > 0) { string selectedTravel = travelListbox.SelectedItems[0].Text; Travel badTravel = new Travel(selectedTravel); travelListbox.SelectedItems[0].Remove(); Util.DeleteTravel(badTravel, travelList, travelDictionary); } } }
public static void AddTravelCaller(Travel newTravel, List<Travel> travelList, Dictionary<string, List<Travel>> travelDictionary) { AddTravel(newTravel, travelList, travelDictionary); UpdateTextFile(fileName, newTravel); }
/// <summary> /// Apply a travel to a game city /// </summary> /// <param name="dailyTravel">truck travel</param> /// <param name="assignedTruck">truck</param> /// <returns>total collected garbage</returns> public int ApplyTravel(Travel dailyTravel, Truck assignedTruck) { int garbageAccumulation = 0; foreach (var tile in dailyTravel) { if (assignedTruck.IsFull) break; if (tile.ModelTile is IHouseTile) { var tilHouse = tile.ModelTile as IHouseTile; var trashAmount = tilHouse.Garbage.Amount; if (trashAmount > 0) { var collectedGarbage = assignedTruck.Swallow(tilHouse.Garbage); garbageAccumulation += collectedGarbage; tilHouse.Garbage = new Trash( tilHouse.Garbage.Type, tilHouse.Garbage.Amount - collectedGarbage ); } } } return garbageAccumulation; }
public static void EditTravel(Travel oldTravel, string newName, List<Travel> travelList, Dictionary<string, List<Travel>> travelDictionary) { Travel newTravel = new Travel(CleanName(newName)); DeleteTravel(oldTravel, travelList, travelDictionary); AddTravelCaller(newTravel, travelList, travelDictionary); }
public bool AddTravel(Travel travel) { if (!IsSearchInProgress) Travels.Add(travel); return !IsSearchInProgress; }