SaveToDb() public method

public SaveToDb ( ) : void
return void
コード例 #1
0
ファイル: RaceIntermediateTest.cs プロジェクト: heinek/ITimeU
 public void TestSetup()
 {
     club = new ClubModel("Test IK");
     eventModel = new EventModel("TestEvent", DateTime.Today);
     eventModel.Save();
     athlete = new AthleteModel("Tester", "Test");
     athlete.StartNumber = 1;
     athlete.Club = club;
     athlete.SaveToDb();
     race = new RaceModel("TestRace", DateTime.Today);
     race.EventId = eventModel.EventId;
     race.Save();
     checkpointOrder = null;
     intermediate = null;
     checkpoint = null;
 }
コード例 #2
0
ファイル: RaceModelTest.cs プロジェクト: heinek/ITimeU
        public void We_Should_Remove_Athlete_From_Race()
        {
            AthleteModel athlete = null;
            int athletesConnectedToRace = 0;
            Given("we have a race and athletes connected to the race", () =>
            {
                athlete = new AthleteModel("Test", "Tester");
                athlete.SaveToDb();
                athlete.ConnectToRace(newRace.RaceId);
                athletesConnectedToRace = newRace.GetAthletes().Count;
            });

            When("we want to remove an athlete from the race", () =>
            {
                athlete.RemoveFromRace(newRace.RaceId);
            });

            Then("the list of athletes should be reduced with 1", () =>
            {
                newRace.GetAthletes().Count.ShouldBe(athletesConnectedToRace - 1);
            });
        }
コード例 #3
0
ファイル: RaceModelTest.cs プロジェクト: heinek/ITimeU
        public void We_Should_Get_All_Athletes_Not_Connected_To_A_Race()
        {
            int athletesNotConnectedToRace = 0;
            AthleteModel athlete = null;
            var aclass = AthleteClassModel.GetOrCreate("12 år");
            Given("we have a race with athletes", () =>
            {
            });

            When("we want to add a new athlete", () =>
            {
                athlete = new AthleteModel("Testing", "Tester");
                athlete.AthleteClass = aclass;
                athlete.SaveToDb();
                athletesNotConnectedToRace = newRace.GetAthletesNotConnected(aclass.Id).Count;
                athlete.ConnectToRace(newRace.RaceId);
            });

            Then("the number of athletes not connected to the race should be reduced by 1", () =>
            {
                newRace.GetAthletesNotConnected(aclass.Id).Count.ShouldBe(athletesNotConnectedToRace - 1);
                athlete.Delete();
            });
        }
コード例 #4
0
ファイル: RaceModelTest.cs プロジェクト: heinek/ITimeU
        public void We_Should_Get_All_Athletes_Connected_To_A_Race()
        {
            AthleteModel athlete = null;
            int athletesConnectedToRace = 0;

            Given("we have a race with athletes", () =>
            {
                athlete = new AthleteModel("Testing", "Tester");
                athlete.SaveToDb();
                athlete.ConnectToRace(newRace.RaceId);
            });

            When("we want to get all the athletes connected to that race", () =>
                {
                    athletesConnectedToRace = newRace.GetAthletes().Count;
                });
            Then("the number of athletes should be 1", () =>
            {
                athletesConnectedToRace.ShouldBe(1);
            });
        }
コード例 #5
0
ファイル: AthleteController.cs プロジェクト: heinek/ITimeU
        /// <summary>
        /// Creates the specified TXT first name.
        /// </summary>
        /// <param name="txtFirstName">First name.</param>
        /// <param name="txtLastName">Last name.</param>
        /// <param name="txtEmail">The email.</param>
        /// <param name="txtPostalAddress">Postal address.</param>
        /// <param name="txtPostalCode">The postal code.</param>
        /// <param name="txtCity">The city.</param>
        /// <param name="txtPhoneNumber">The phone number.</param>
        /// <param name="genderId">The gender id.</param>
        /// <param name="birthdateId">The birthdate id.</param>
        /// <param name="txtStartNumber">The start number.</param>
        /// <param name="clubId">The club id.</param>
        /// <param name="classId">The class id.</param>
        /// <returns></returns>
        public ActionResult Create(string txtFirstName, string txtLastName, string txtEmail, string txtPostalAddress, string txtPostalCode, string txtCity,
                                    string txtPhoneNumber, string genderId, string birthdateId, string txtStartNumber, string clubId, string classId)
        {
            int startnum = 0;
                int.TryParse(txtStartNumber, out startnum);
            if (!IsValidInput(txtFirstName,txtLastName,txtEmail,txtStartNumber,clubId) ||
                AthleteModel.StartnumberExistsInDb(startnum))
            {
                ViewBag.IsValidInput = false;
                ViewBag.IsAthleteCreated = false;
                setViewData();
                return View("Index", ClubModel.GetAll());
            }
            else
            {
                int birthdate = 0;
                int gender = 0, athleteclubid = 0, athleteclassid = 0;

                int.TryParse(genderId, out gender);
                int.TryParse(birthdateId, out birthdate);
                int.TryParse(clubId, out athleteclubid);
                int.TryParse(classId, out athleteclassid);

                Gender getGender = getGenderNameById(gender);
                string gendername = "";
                if (getGender != null)
                {
                    gendername = getGender.Name;
                }
                BirthDate getBirthday = getBirthDateById(birthdate);
                int birthyear = 0;
                if (getBirthday != null)
                {
                    birthyear = getBirthday.BirthYear;
                }

                ClubModel athclubobj = null;
                if (athleteclubid != 0)
                {
                    athclubobj = new ClubModel(athleteclubid);
                }

                AthleteClassModel athclassobj = null;
                if (athleteclassid != 0)
                {
                    athclassobj = new AthleteClassModel(athleteclassid);
                }

                AthleteModel athlete = new AthleteModel(txtFirstName, txtLastName, txtEmail, txtPostalAddress,
                                    txtPostalCode, txtCity, gendername, birthyear, txtPhoneNumber, startnum, athclubobj, athclassobj);
                athlete.SaveToDb();
                return RedirectToAction("ResetFormField");
            }
        }
コード例 #6
0
ファイル: AthleteController.cs プロジェクト: heinek/ITimeU
        public ActionResult EditAthleteDetails(string txtathleteId, string txtfirstName, string txtlastName, string txtemail, string txtpostalAddress, string txtpostalCode, string txtcity,
                                    string txtphoneNumber, string txtgender, string txtbirthDate, string txtstartNumber, string txtathleteClass)
        {
            if (!IsValidInput(txtfirstName, txtlastName, txtemail, txtstartNumber))
            {
                return Content("invalid");
            }
            else
            {
                int athleteid = 0;
                int.TryParse(txtathleteId, out athleteid);
                int birthdate = 0, startnum = 0;
                int gender = 0, athleteclass = 0;

                int.TryParse(txtgender, out gender);
                int.TryParse(txtbirthDate, out birthdate);
                int.TryParse(txtstartNumber, out startnum);
                int.TryParse(txtathleteClass, out athleteclass);

                Gender getGender = getGenderNameById(gender);
                string gendername = "";
                if (getGender != null)
                {
                    gendername = getGender.Name;
                }
                BirthDate getBirthday = getBirthDateById(birthdate);
                int birthyear = 0;
                if (getBirthday != null)
                {
                    birthyear = getBirthday.BirthYear;
                }

                Athlete athleteDb = new Athlete();
                athleteDb.ID = athleteid;
                athleteDb.FirstName = txtfirstName;
                athleteDb.LastName = txtlastName;
                athleteDb.Email = txtemail;
                athleteDb.PostalAddress = txtpostalAddress;
                athleteDb.PostalCode = txtpostalCode;
                athleteDb.PostalPlace = txtcity;
                athleteDb.Gender = gendername;
                athleteDb.Birthday = birthyear;
                athleteDb.Phone = txtphoneNumber;
                athleteDb.Startnumber = startnum;
                athleteDb.ClassID = athleteclass;

                AthleteModel athlete = new AthleteModel(athleteDb);

                athlete.SaveToDb();
                return Content("updated");
            }
        }