public ActionResult Create([Bind(Include = "FlightID,FlightNumber,FlightFromCountry,FlightToCountry,FlightPrice,FlightDateTimeTakeOff,FlightDuration,FlightDateTimeLanding,PlainID,FlightTotalAviableSeats,FlightStatus")] Flight flight) { Plain plain = db.Plains.Find(flight.PlainID); flight.FlightTotalAviableSeats = plain.PlainTotalSeats; flight.FlightDateTimeLanding = flight.FlightDateTimeTakeOff; flight.FlightDateTimeLanding = flight.FlightDateTimeLanding.AddHours(flight.FlightDuration); flight.FlightStatus = "ON TIME"; var plains = from p in db.Plains select p.PlainNumber; plains = plains.Distinct(); ViewBag.allPlains = plains.ToList(); if (ModelState.IsValid) { db.Flights.Add(flight); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlainID = new SelectList(db.Plains, "PlainID", "PlainID", flight.PlainID); return(View(flight)); }
public string Format(MessageChain chain) { var cmps = new LinkedList <object>(); foreach (var comp in chain) { cmps.AddLast(comp switch { Plain plain => new { type = "text", data = new { text = plain.Text } }, Face face => new { type = "face", data = new { id = face.FaceId } }, At at => new { type = "at", data = new { qq = at.TargetId.ToString() } }, ImageBase { Source: UrlSource source } image => new { type = "image", data = new { file = source.Url.AbsoluteUri, type = image is Flash ? "flash" : "image", cache = 0 } }, ImageBase { Source: StreamSource source } image => new { type = "image", data = new { file = GetBase64Url(source.Data), type = image is Flash ? "flash" : "image", cache = 0 } }, AtAll atall => new { type = "at", data = new { qq = "atall" } }, Quote quote => new { type = "reply", data = new { id = quote.MessageId } }, Poke poke => new { type = "poke", data = new { type = ((int)poke.Name).ToString(), id = "-1" } }, XmlContent xml => new { type = "xml", data = new { data = xml.Content } }, JsonContent json => new { type = "json", data = new { data = json.Content } }, Music music => new { type = "music", data = new { type = music.Type switch { Music.MusicSource.QqMusic => "qq", Music.MusicSource.Music163 => "163", Music.MusicSource.XiaMi => "xm" },
public MainVM() //constructor { string version; try { //// get deployment version version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); } catch (InvalidDeploymentException) { //// you cannot read publish version when app isn't installed //// (e.g. during debug) version = "debugging, not installed"; } log.Info($"Clinic System log in, version: {version}."); BTN_File = new FILEinput(this); BTN_YM = new YMinput(this); BTN_SE = new BEinput(this); BTN_ACT = new Plain(this); BTN_RFR = new DATArefresh(this); Refresh_Data(); }
//Constructeur private TileFactory() { TileDesert = new Desert(); TilePlain = new Plain(); TileSwamp = new Swamp(); TileVolcano = new Volcano(); }
private static async UniTask <Plain> CreateFloor(WorldLayer layer) { var timing = layer.GetValidScreen().TimingPoints.Update; var plain = new Plain(); plain.Scale = new Vector3(40f); plain.Shader = new PhongShader(); var config = new TextureConfig(TextureExpansionMode.NearestNeighbor, TextureShrinkMode.NearestNeighbor, TextureMipmapMode.None, TextureWrapMode.ClampToEdge, TextureWrapMode.ClampToEdge); var texture = await Resources.Sandbox["floor.png"].LoadTextureAsync(config, timing); plain.AddComponent(texture); plain.Rotation = Quaternion.FromAxisAngle(Vector3.UnitX, -90.ToRadian()); plain.Updated += _ => { var k = plain.GetValidScreen().Keyboard; if (k.IsPress(Elffy.InputSystem.Keys.Down)) { plain.Position.Y -= 0.5f; } else if (k.IsPress(Elffy.InputSystem.Keys.Up)) { plain.Position.Y += 0.5f; } }; return(await plain.Activate(layer)); }
public World() { _questCreator = new QuestCreator(); P1Plain = new Plain(Length, Width); P2Plain = new Plain(Length, Width); P1Resources = new PlayerResources(0, 0, 0); P2Resources = new PlayerResources(0, 0, 0); P1SideQuest = new PlayerSideQuest(); P2SideQuest = new PlayerSideQuest(); P1Action = new PlayerAction(2, 0, 0, 0); P2Action = new PlayerAction(2, 0, 0, 0); var resourceTypes = GenerateResourceTypes(); Quests = _questCreator.CreateQuests( resourceTypes.Count(x => x == ResourceType.Red), resourceTypes.Count(x => x == ResourceType.Green), resourceTypes.Count(x => x == ResourceType.Blue)); GenerateResourceMap(resourceTypes); GenerateTileMap(); }
/// <summary> /// Save a plain in the repo /// </summary> public void CreatePlains(Plain plain) { if (plain == null) { throw new ArgumentNullException("plain"); } using (WriteLock.Write()) { using (var connection = CreateConnection()) { connection.RunInTransaction(db => { using (var statement = db.PrepareStatement("INSERT INTO Plains (Name, MaxSimultaneousScreens) values (@Name, @MaxSimultaneousScreens)")) { statement.TryBind("@Name", plain.Name); statement.TryBind("@MaxSimultaneousScreens", plain.MaxSimultaneousScreens); statement.MoveNext(); } var createdPlain = GetPlain(plain.Id, false); if (createdPlain == null) { throw new ApplicationException("created plain should never be null"); } }, TransactionMode); } } }
public void MergeFrom(RichTextSegment other) { if (other == null) { return; } switch (other.SegmentCase) { case SegmentOneofCase.UserInfo: if (UserInfo == null) { UserInfo = new global::AcFunDanmu.CommonActionSignalRichText.Types.UserInfoSegment(); } UserInfo.MergeFrom(other.UserInfo); break; case SegmentOneofCase.Plain: if (Plain == null) { Plain = new global::AcFunDanmu.CommonActionSignalRichText.Types.PlainSegment(); } Plain.MergeFrom(other.Plain); break; case SegmentOneofCase.Image: if (Image == null) { Image = new global::AcFunDanmu.CommonActionSignalRichText.Types.ImageSegment(); } Image.MergeFrom(other.Image); break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public void PlainItem__CreatePyramidOfElements() { var expected = new int[] { 55, 94, 48, 95, 30, 28, 77, 71, 26, 28 }; var plain = new Plain(); plain.Store(expected); var root = plain.Root; Assert.AreEqual(expected[0], root.Item); Assert.AreEqual(expected[1], root.Left.Item); Assert.AreEqual(expected[2], root.Right.Item); Assert.AreEqual(expected[3], root.Left.Left.Item); Assert.AreEqual(expected[4], root.Left.Right.Item); Assert.AreEqual(expected[5], root.Right.Right.Item); Assert.AreEqual(expected[6], root.Left.Left.Left.Item); Assert.AreEqual(expected[7], root.Left.Left.Right.Item); Assert.AreEqual(expected[7], root.Right.Left.Left.Item); Assert.AreEqual(expected[8], root.Left.Right.Right.Item); Assert.AreEqual(expected[8], root.Right.Right.Left.Item); Assert.AreEqual(expected[9], root.Right.Right.Right.Item); var occurenceCounter = new OccurenceCounter(); var reports = occurenceCounter.CountOccurences(root); var report = reports.First(); Assert.AreEqual(report.Frequence, 2); Assert.AreEqual(report.Sum, 159); }
// PUT api/Plains/5 public IHttpActionResult PutPlain(int id, Plain plain) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != plain.ID) { return(BadRequest()); } db.Entry(plain).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PlainExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Add a new display item /// </summary> /// <param name="machineName">name of the sender machine</param> /// <param name="appDomain">name of the sender appdomain</param> /// <param name="time">sender time</param> /// <param name="text">display text</param> /// <param name="parentID">parent display item id</param> /// <returns>the new created id for the item</returns> public string AddNew(string machineName, string appDomain, string time, string text, string parentID = null) { _idCounter++; ConsoleViewItem newItem = new ConsoleViewItem(_idCounter.ToString(), machineName, appDomain, time, text); Plain.Add(newItem); if (!String.IsNullOrWhiteSpace(parentID)) { ConsoleViewItem parentItem = LookupForItem(parentID); if (null != parentItem) { parentItem.Items.Add(newItem); } else { Hierarchy.Add(newItem); } } else { Hierarchy.Add(newItem); } return(_idCounter.ToString()); }
public static MessageChainBuilder AddPlain(this MessageChainBuilder builder, string text) { Plain plain = new Plain(text); builder.Add(plain); return(builder); }
public ActionResult DeleteConfirmed(int id) { Plain plain = db.Plains.Find(id); db.Plains.Remove(plain); db.SaveChanges(); return(RedirectToAction("Index")); }
public Dictionary <int, int> GetPlain() { Plain plain = new Plain(); Dictionary <int, int> numbers = plain.GeneratePlain(); //numbers.Reverse().ToDictionary<> return(numbers); }
public static Cipher Encrypt(Plain plain) { var cipher = new Cipher(); cipher.Salt = BCrypt.Net.BCrypt.GenerateSalt(SaltRevision.Revision2B); cipher.Hash = BCrypt.Net.BCrypt.HashPassword(plain.Password, cipher.Salt); return(cipher); }
public void EqualsOperator_AnyAndNull_ReturnsFalse() { // Arrange Plain p1 = new Plain("a dog"); // Act bool assert = p1 == null; // Assert Assert.IsFalse(assert); }
public void Equals_WithNull_ReturnsFalse() { // Arrange Plain p1 = new Plain("a dog"); // Act bool assert = p1.Equals(null); // Assert Assert.IsFalse(assert); }
public void EqualsOperator_NullAndAny_ReturnsFalse() { // Arrange Plain p1 = new Plain("a dog"); // Act bool assert = null == p1; // Assert Assert.IsFalse(assert); }
public void Equals_WithSelf_ReturnsTrue() { // Arrange Plain p1 = new Plain("a dog"); // Act bool assert = p1.Equals(p1); // Assert Assert.IsTrue(assert); }
public ActionResult Edit([Bind(Include = "PlainID,PlainTotalSeats")] Plain plain) { if (ModelState.IsValid) { db.Entry(plain).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(plain)); }
public void EqualsOperator_OneAndOne_ReturnsTrue() { // Arrange var p1 = new Plain("a dog"); var p2 = new Plain("a dog"); // Act var assert = p1 == p2; // Assert Assert.IsTrue(assert); }
public void Equals_WithSame_ReturnsTrue() { // Arrange var p1 = new Plain("a dog"); var p2 = new Plain("a dog"); // Act var assert = p1.Equals(p2); // Assert Assert.IsTrue(assert); }
public void Equals_WithOther_ReturnsFalse() { // Arrange Plain p1 = new Plain("a dog"); Plain p2 = new Plain("a cat"); // Act bool assert = p1.Equals(p2); // Assert Assert.IsFalse(assert); }
public IHttpActionResult GetPlain(int id) { Plain plain = db.Plains.Find(id); if (plain == null) { return(NotFound()); } return(Ok(plain)); }
public void EqualsOperator_OneAndOther_ReturnsFalse() { // Arrange Plain p1 = new Plain("a dog"); Plain p2 = new Plain("a cat"); // Act bool assert = p1 == p2; // Assert Assert.IsFalse(assert); }
public void ApplyTo_WhenEqualPlainObjects_ThenSuccess() { var expected = new Plain() { Id = 1, Name = "Two" }; var actual = new Plain() { Id = 1, Name = "Two" }; Assert.That(actual, Is.Not.SameAs(expected)); var constraint = new TwinConstraint(expected); var result = constraint.ApplyTo(actual) as TwinConstraintResult; Assert.That(result, Is.Not.Null); Assert.That(result.IsSuccess, Is.True); Assert.That(result.Members.Count(), Is.EqualTo(2)); }
public IHttpActionResult PostPlain(Plain plain) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Plains.Add(plain); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = plain.ID }, plain)); }
public string Format(MessageChain chain) { return(string.Join(string.Empty, chain.Where(x => x.GetType().GetCustomAttribute <SerializableAttribute>() != null).Select(x => PlainSelector(x)))); string PlainSelector(MessageComponent comp) { return(comp switch { Plain it => it.Text, _ => $"[hyper.{comp.TypeName.ToLower()}({CodeSelector(comp)})]" }); }
private ITile[,] initMap(int sizeX, int sizeY) { var TileMap = new ITile[sizeX, sizeY]; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { TileMap[x, y] = new Plain(x, y); } } return(TileMap); }
public void PlainItem__CreateFirstElement() { const int expected = 10; var plain = new Plain(); plain.Store(expected); var root = plain.Root; Assert.AreEqual(expected, root.Item); Assert.IsNull(root.Right); Assert.IsNull(root.Left); }
public void PlainItem__CreateSecondAndThirdElement() { var expected = new int[] { 10, 23, 4 }; var plain = new Plain(); plain.Store(expected); var root = plain.Root; Assert.AreEqual(expected[0], root.Item); Assert.AreEqual(expected[1], root.Left.Item); Assert.AreEqual(expected[2], root.Right.Item); }
public void ApplyTo_WhenDifferentPlainObjects_ThenFailed() { var expected = new Plain() { Id = 1, Name = "Two" }; var actual = new Plain() { Id = 2, Name = "One" }; var constraint = new TwinConstraint(expected); var result = constraint.ApplyTo(actual) as TwinConstraintResult; Assert.That(result, Is.Not.Null); Assert.That(!result.IsSuccess); Assert.That(result.IsSuccess, Is.False); Assert.That(result.Members.Count(), Is.EqualTo(2)); }