Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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"
                            },
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 //Constructeur
 private TileFactory()
 {
     TileDesert  = new Desert();
     TilePlain   = new Plain();
     TileSwamp   = new Swamp();
     TileVolcano = new Volcano();
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
    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();
    }
Ejemplo n.º 7
0
        /// <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);
                }
            }
        }
Ejemplo n.º 8
0
                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);
                }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 11
0
        /// <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());
        }
Ejemplo n.º 12
0
        public static MessageChainBuilder AddPlain(this MessageChainBuilder builder, string text)
        {
            Plain plain = new Plain(text);

            builder.Add(plain);
            return(builder);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        public void EqualsOperator_AnyAndNull_ReturnsFalse()
        {
            // Arrange
            Plain p1 = new Plain("a dog");
            // Act
            bool assert = p1 == null;

            // Assert
            Assert.IsFalse(assert);
        }
Ejemplo n.º 17
0
        public void Equals_WithNull_ReturnsFalse()
        {
            // Arrange
            Plain p1 = new Plain("a dog");
            // Act
            bool assert = p1.Equals(null);

            // Assert
            Assert.IsFalse(assert);
        }
Ejemplo n.º 18
0
        public void EqualsOperator_NullAndAny_ReturnsFalse()
        {
            // Arrange
            Plain p1 = new Plain("a dog");
            // Act
            bool assert = null == p1;

            // Assert
            Assert.IsFalse(assert);
        }
Ejemplo n.º 19
0
        public void Equals_WithSelf_ReturnsTrue()
        {
            // Arrange
            Plain p1 = new Plain("a dog");
            // Act
            bool assert = p1.Equals(p1);

            // Assert
            Assert.IsTrue(assert);
        }
Ejemplo n.º 20
0
 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));
 }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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));
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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));
        }
Ejemplo n.º 28
0
        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)})]"
                });
            }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 31
0
        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);
        }
Ejemplo n.º 32
0
        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));
        }