Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                rUsed = new Race();
                oldRUsed = new Race();
                using (var db = new ClubSiteContext())
                {
                    rUsed = (from races in db.Races
                             orderby races.RaceDate descending, races.Name
                             select races).FirstOrDefault();

                    if (rUsed == null)
                    {
                        rUsed = new Race();
                        X.Msg.Alert("Atención", "No hay ningúna competición registrada en la Base de datos.").Show();
                    }

                    //Load data for racetypes combobox
                    LoadDataInGridForRaceTypes();

                    //Load data for clubbers combobox
                    LoadDataInGridForClubbers();

                    //Load data for Members in Race
                    LoadDataInGridForMembersInRace();

                    oldRUsed.CopyRace(rUsed);
                    LoadRaceInForm(rUsed);
                }
            }
        }
Exemplo n.º 2
0
        public void CopyRace()
        {
            Int32 anID = 10;
            string aName = "Ejemplo de carrera";
            DateTime aRaceDate = DateTime.Now;
            string aStreet = "Street";
            string aNumber = "1a";
            string aCity = "City";
            string aCountry = "Country";
            string aPostalCode = "18007";
            Address anAddress = new Address(aStreet, aNumber, aCity, aCountry, aPostalCode);
            Int32 aRaceTypeId = 20;
            string aMemo = "memo";
            double aLatitud = 3;
            double aLongitud = 36;
            string aImgURL = "imagen url";
            int aPartMasc = 1000;
            int aPartFem = 100;

            Race aRace = new Race(anID, aName, aRaceDate, anAddress, aRaceTypeId, aMemo, aImgURL, aLongitud, aLatitud, aPartMasc, aPartFem);
            Race aRace2 = new Race();

            Assert.AreEqual(anID, aRace.Id);
            Assert.AreEqual(aName, aRace.Name);
            Assert.AreEqual(aRaceDate.ToShortDateString(), aRace.RaceDate.ToShortDateString());
            Assert.AreEqual(aStreet, aRace.Address.Street);
            Assert.AreEqual(aNumber, aRace.Address.Number);
            Assert.AreEqual(aCity, aRace.Address.City);
            Assert.AreEqual(aCountry, aRace.Address.Country);
            Assert.AreEqual(aPostalCode, aRace.Address.PostalCode);
            Assert.AreEqual(aRaceTypeId, aRace.RaceTypeID);
            Assert.AreEqual(aMemo, aRace.Memo);
            Assert.AreEqual(aPartFem, aRace.PartFem);
            Assert.AreEqual(aPartMasc, aRace.PartMasc);

            Assert.AreEqual(0, aRace2.Id);
            Assert.AreEqual(null, aRace2.Name);
            Assert.AreEqual(DateTime.Now.ToShortDateString(), aRace2.RaceDate.ToShortDateString());
            Assert.AreEqual(null, aRace2.Address);
            Assert.AreEqual(0, aRace2.RaceTypeID);
            Assert.AreEqual(null, aRace2.Memo);
            Assert.AreEqual(null, aRace2.ImageURL);
            Assert.AreEqual(0, aRace2.Latitud);
            Assert.AreEqual(0, aRace2.Longitud);
            Assert.AreEqual(0, aRace2.PartFem);
            Assert.AreEqual(0, aRace2.PartMasc);

            aRace2.CopyRace(aRace);
            aRace.ClearRace();

            Assert.AreEqual(anID, aRace2.Id);
            Assert.AreEqual(aName, aRace2.Name);
            Assert.AreEqual(aRaceDate.ToShortDateString(), aRace2.RaceDate.ToShortDateString());
            Assert.AreEqual(aStreet, aRace2.Address.Street);
            Assert.AreEqual(aNumber, aRace2.Address.Number);
            Assert.AreEqual(aCity, aRace2.Address.City);
            Assert.AreEqual(aCountry, aRace2.Address.Country);
            Assert.AreEqual(aPostalCode, aRace2.Address.PostalCode);
            Assert.AreEqual(aRaceTypeId, aRace2.RaceTypeID);
            Assert.AreEqual(aMemo, aRace2.Memo);
            Assert.AreEqual(aImgURL, aRace2.ImageURL);
            Assert.AreEqual(aLatitud, aRace2.Latitud);
            Assert.AreEqual(aLongitud, aRace2.Longitud);
            Assert.AreEqual(aPartFem, aRace2.PartFem);
            Assert.AreEqual(aPartMasc, aRace2.PartMasc);

            Assert.AreEqual(0, aRace.Id);
            Assert.AreEqual(null, aRace.Name);
            Assert.AreEqual(DateTime.Now.ToShortDateString(), aRace.RaceDate.ToShortDateString());
            Assert.AreEqual(null, aRace.Address);
            Assert.AreEqual(0, aRace.RaceTypeID);
            Assert.AreEqual(null, aRace.Memo);
            Assert.AreEqual(null, aRace.ImageURL);
            Assert.AreEqual(0, aRace.Latitud);
            Assert.AreEqual(0, aRace.Longitud);
            Assert.AreEqual(0, aRace.PartFem);
            Assert.AreEqual(0, aRace.PartMasc);
        }