public ActionResult DeleteConfirmed(int id)
        {
            Clark clark = db.Clarks.Find(id);

            db.Clarks.Remove(clark);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,Name,Salary,Position,TotalSalary")] Clark clark)
 {
     if (ModelState.IsValid)
     {
         db.Entry(clark).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(clark));
 }
        // GET: /Clark/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Clark clark = db.Clarks.Find(id);

            if (clark == null)
            {
                return(HttpNotFound());
            }
            return(View(clark));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Salary,Position,TotalSalary")] Clark clark)
        {
            //   var sum = db.Clarks.Sum(i => i.Salary);
            //    clark.TotalSalary = sum;
            if (ModelState.IsValid)
            {
                db.Clarks.Add(clark);
                db.SaveChanges();

                var sum = db.Clarks.Sum(i => i.Salary);
                clark.TotalSalary = sum;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(clark));
        }
Exemple #5
0
        public void PersonDataCompletionDOB()
        {
            const string a = @"{{persondata
            |NAME=
            |DATE OF BIRTH=
            |DATE OF DEATH=}}", a2 = @"{{persondata
            |NAME= Doe, John
            |DATE OF BIRTH= 27 June 1950
            |DATE OF DEATH=}}", i1 = @"{{infobox foo| dateofbirth = 27 June 1950}}", i2 = @"{{infobox foo| dateofbirth = {{birth date|1950|06|27}}}}"
            , i2b           = @"{{infobox foo| dateofbirth = {{birth date|df=y|1950|06|27}}}}",
                         a3 = @"{{persondata
            |NAME= Doe, John
            |DATE OF BIRTH=
            |DATE OF DEATH=}}";

            Assert.AreEqual(i1 + a2, Parsers.PersonData(i1 + a, "John Doe"));
            Assert.AreEqual(i1 + a2, Parsers.PersonData(i1 + @"{{persondata
            |NAME= Doe, John
            |date of birth=
            |date of death=}}", "John Doe"));
            Assert.AreEqual(i1.Replace("27 June", "June 27,") + a2.Replace("27 June", "June 27,"), Parsers.PersonData(i1.Replace("27 June", "June 27,") + a.Replace("27 June", "June 27,"), "John Doe"));
            Assert.AreEqual(i2 + a2.Replace("27 June 1950", "1950-06-27"), Parsers.PersonData(i2 + a, "John Doe"));
            Assert.AreEqual(i2.Replace(@"{{birth date|1950|06|27}}", @"{{birth-date|27 June 1950|27 June 1950}}") + a2,
                            Parsers.PersonData(i2.Replace(@"{{birth date|1950|06|27}}", @"{{birth-date|27 June 1950|27 June 1950}}") + a, "John Doe"));
            Assert.AreEqual(i2.Replace("27}}", "27}} in London") + a2.Replace("27 June 1950", "1950-06-27"),
                            Parsers.PersonData(i2.Replace("27}}", "27}} in London") + a, "John Doe"), "Completes persondata from {{birth date}} when extra data in infobox field");
            Assert.AreEqual(i2b.Replace("27}}", "27}} in London") + a2,
                            Parsers.PersonData(i2b.Replace("27}}", "27}} in London") + a, "John Doe"), "Completes persondata from {{birth date}} when extra data in infobox field");

            string i3 = i1.Replace("27 June 1950", @"{{dda|2005|07|20|1950|06|27|df=yes}}");

            Assert.AreEqual(i3 + a2.Replace("DEATH=", "DEATH= 20 July 2005"), Parsers.PersonData(i3 + a, "John Doe"), "takes dates from {{dda}}");

            string i4 = @"{{infobox foo| birthyear = 1950 | birthmonth=06 | birthday=27}}";

            Assert.AreEqual(i4 + a2 + @"{{use dmy dates}}", Parsers.PersonData(i4 + a + @"{{use dmy dates}}", "John Doe"), "takes dates from birthyear etc. fields");

            string i5 = @"{{infobox foo| yob = 1950 | mob=06 | dob=27}}";

            Assert.AreEqual(i5 + a2 + @"{{use dmy dates}}", Parsers.PersonData(i5 + a + @"{{use dmy dates}}", "John Doe"), "takes dates from birthyear etc. fields");

            Assert.AreEqual(i1 + a + a, Parsers.PersonData(i1 + a + a, "John Doe"), "no change when multiple personData templates");

            string i6 = i1.Replace("27 June 1950", @"{{dda|2005|07|00|1950|06|00|df=yes}}");

            Assert.AreEqual(i6 + a3, Parsers.PersonData(i6 + a3, "John Doe"), "ignores incomplete/zerod dates from {{dda}}");

            string UnformatedDOB = @"'''Fred''' (born 27 June 1950) was great [[Category:1950 births]]";

            Assert.AreEqual(UnformatedDOB + a2, Parsers.PersonData(UnformatedDOB + a, "John Doe"), "sets full birth date when matches category");

            UnformatedDOB = @"'''Fred''' (born June 27, 1950) was great [[Category:1950 births]] {{use dmy dates}}";
            Assert.AreEqual(UnformatedDOB + a2, Parsers.PersonData(UnformatedDOB + a, "John Doe"), "sets full birth date when matches category, American date");

            UnformatedDOB = UnformatedDOB.Replace(@"[[Category:1950 births]]", "");
            Assert.AreEqual(UnformatedDOB + a3, Parsers.PersonData(UnformatedDOB + a3, "John Doe"), "not set when no birth category");

            UnformatedDOB = @"'''Fred''' (born 27 June 1949) was great [[Category:1950 births]]";
            Assert.AreEqual(UnformatedDOB + a2.Replace("27 June 1950", "1950"), Parsers.PersonData(UnformatedDOB + a, "John Doe"), "not set when full birth date doesn't match category");

            UnformatedDOB = @"'''Fred''' (born circa 27 June 1950) was great [[Category:1950 births]]";
            Assert.AreEqual(UnformatedDOB + a2.Replace("27 June 1950", "1950"), Parsers.PersonData(UnformatedDOB + a, "John Doe"), "only year set when circa date");

            UnformatedDOB = @"'''Fred''' (reigned 27 June 1950 – 11 May 1990) was great";
            Assert.AreEqual(UnformatedDOB + a2.Replace(" 27 June 1950", ""), Parsers.PersonData(UnformatedDOB + a, "John Doe"), "No dates set when reigned");

            UnformatedDOB = @"'''Fred''' (baptized 27 June 1950 – 11 May 1990) was great";
            Assert.AreEqual(UnformatedDOB + a2.Replace(" 27 June 1950", ""), Parsers.PersonData(UnformatedDOB + a, "John Doe"), "No dates set when baptized");

            const string Clark = @"
{{use mdy dates}}
{{Infobox college coach
| name          = Lyal W. Clark
| birth_date   = {{birth date|mf=yes|1904|07|04}}
}}

{{Persondata <!-- Metadata: see [[Wikipedia:Persondata]]. -->
| NAME              = Clark, Lyal W.
| ALTERNATIVE NAMES =
| SHORT DESCRIPTION = American college football coach
| DATE OF BIRTH     =
| PLACE OF BIRTH    =
| DATE OF DEATH     =
| PLACE OF DEATH    =
}}
[[Category:1904 births]]";

            Assert.AreEqual(Clark.Replace(@"| DATE OF BIRTH     =", @"| DATE OF BIRTH     = July 4, 1904"), Parsers.PersonData(Clark, "A"));

            string small = i1.Replace("27 June 1950", @"<small>27 June 1950</small>");

            Assert.AreEqual(small + a2, Parsers.PersonData(small + a, "John Doe"), "small tags removed");

            string twoDDA = i1.Replace("27 June 1950", @"{{dda|2005|07|20|1950|06|27|df=yes}} {{dda|2009|07|20|1950|06|27|df=yes}}");

            Assert.AreEqual(twoDDA + a2, Parsers.PersonData(twoDDA + a, "John Doe"), "Ignores conflicting {{dda}}");
        }
Exemple #6
0
        public Map(string fileName, Game1 game, Mapper mapper, List <String> enemyList)
        {
            FileInputHandler fileIn = new FileInputHandler(game);

            tiles          = fileIn.parseToArray(fileName);
            this.gameRef   = game;
            this.mapper    = mapper;
            this.enemyList = enemyList;

            loadList = new List <Sprite>();
            int    dim = 16;
            string s   = "";

            for (int x = 0; x < dim; x++)
            {
                for (int y = 0; y < dim; y++)
                {
                    Vector2 position = new Vector2(x * 64, y * 64);
                    s = this.tiles[y, x];
                    //if (s.Equals("0"))
                    //{
                    //    ts = new TileSprite(gameRef.Content.Load<Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                    //    loadList.Add(ts);
                    //}
                    if (s.Contains("map_"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        loadList.Add(ts);
                        string selectedBoss = s.Substring(s.IndexOf("_") + 1);
                        Enemy  bossObject;
                        switch (selectedBoss)
                        {
                        case "clark":
                            bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "pay":
                            bossObject = new JerryPay(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "fletcher":
                            bossObject = new Fletcher(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "halliday":
                            bossObject = new Halliday(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        case "king_james":
                            bossObject = new Boss(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;

                        default:
                            bossObject = new Clark(gameRef.Character.Level, gameRef, gameRef.Character);
                            break;
                        }
                        BossSprite combatSprite = new BossSprite(gameRef.Content.Load <Texture2D>(@"Images/map" + s.Substring(s.IndexOf('_'))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero, gameRef, bossObject);
                        loadList.Add(combatSprite);
                    }
                    else if (s.Contains("3d"))
                    {
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        loadList.Add(ts);
                    }
                    else if (s.Contains("i"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        Treasure t = new Treasure(gameRef.Content.Load <Texture2D>(@"Images/mapItem"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(t);
                    }
                    else if (s.Contains("d"))
                    {
                        int    i     = 0;
                        string mapID = s.Substring(1, 2);

                        float placeAtX = (float.Parse(s.Substring(s.IndexOf(";") + 1, 2))) * 64;
                        float placeAtY = (float.Parse(s.Substring(s.IndexOf("_") + 1, 2))) * 64;
                        Door  d        = new Door(gameRef.Content.Load <Texture2D>(@"Images/tiled"), position, 0, mapID, mapper, new Vector2(placeAtX, placeAtY), gameRef);
                        d.passable       = false;
                        d.isInteractable = true;
                        loadList.Add(d);
                    }
                    else if (s.Contains("k"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        Key k = new Key(gameRef.Content.Load <Texture2D>(@"Images/key"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(k);
                    }

                    else if (s.Contains("l"))
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        LockedDoor ld = new LockedDoor(gameRef.Content.Load <Texture2D>(@"Images/lockedDoor"), position, 0, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(ld);
                    }
                    else if (s.Contains("s"))
                    {
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + (s.Substring(0, 1))), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        ShopSprite ss = new ShopSprite(gameRef.Content.Load <Texture2D>(@"Images/shop"), position, 25, mapper, gameRef);
                        loadList.Add(ts);
                        loadList.Add(ss);
                    }
                    else if (s == "0")
                    {
                        int wallType = r.Next(0, 9);
                        switch (wallType)
                        {
                        case 0:
                            break;

                        case 1:
                            wallType = 0;
                            break;

                        case 2:
                            wallType = 1;
                            break;

                        case 3:
                            wallType = 1;
                            break;

                        case 4:
                            wallType = 2;
                            break;

                        case 5:
                            wallType = 2;
                            break;

                        case 6:
                            wallType = 3;
                            break;

                        case 7:
                            wallType = 1;
                            break;

                        case 8:
                            wallType = 2;
                            break;
                        }
                        ts          = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/wallTile" + wallType), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        ts.passable = false;
                        loadList.Add(ts);
                    }
                    else
                    {
                        ts = new TileSprite(gameRef.Content.Load <Texture2D>(@"Images/tile" + s), position, new Point(32, 32), -25, new Point(0, 0), new Point(1, 1), Vector2.Zero);
                        if (s == "0" || s == "b")
                        {
                            ts.passable = false;
                        }
                        loadList.Add(ts);
                    }
                }
            }
        }