Esempio n. 1
0
 public AthleteModel(string firstName, string lastName, int? birthday, ClubModel club, AthleteClassModel athleteClass, int? startNumber, int id = EMPTY_ID)
 {
     SetDefaultId();
     FirstName = firstName;
     LastName = lastName;
     Birthday = birthday;
     Club = club;
     AthleteClass = athleteClass;
     StartNumber = startNumber;
 }
Esempio n. 2
0
 public ActionResult Edit(int id, AthleteClassModel model)
 {
     try
     {
         var athleteclass = AthleteClassModel.GetById(id);
         athleteclass.Name = model.Name;
         athleteclass.Update();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Esempio n. 3
0
 public AthleteModel(string firstName, string lastName, string email, string address, string postalcode, string city, string gender, int? birthday, string phonenumber, int? startNumber, ClubModel club, AthleteClassModel athleteClass)
 {
     SetDefaultId();
     FirstName = firstName;
     LastName = lastName;
     Birthday = birthday;
     Club = club;
     AthleteClass = athleteClass;
     StartNumber = startNumber;
     PostalAddress = address;
     PostalCode = postalcode;
     City = city;
     Gender = gender;
     PhoneNumber = phonenumber;
     Email = email;
 }
Esempio n. 4
0
 public ActionResult Create(AthleteClassModel model)
 {
     try
     {
         var athleteclass = new AthleteClassModel()
         {
             Name = model.Name
         };
         athleteclass.SaveToDb();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Esempio n. 5
0
        public void When_Fetching_An_Athlete_Class_That_Does_Not_Exists_In_The_Db_We_Should_Create_That_Class()
        {
            int previousCount = -1;

            Given("we want to fetch a spesific class called G17");

            When("we fetch a class that does not exists (G17)", () =>
            {
                AthleteClassModel.DeleteIfExists("G17");
                previousCount = AthleteClassModel.GetAll().Count;
                athleteClass = AthleteClassModel.GetOrCreate("G17");
            });

            Then("we shold get a class and a new DB row should have been added", () =>
            {
                athleteClass.Name.ShouldBe("G17");
                AthleteClassModel.GetAll().Count.ShouldBe(previousCount + 1);
            });
        }
Esempio n. 6
0
        public void When_Fetching_An_Athlete_Class_That_Exists_In_The_Db_We_Should_Get_That_Class()
        {
            When_Fetching_An_Athlete_Class_That_Does_Not_Exists_In_The_Db_We_Should_Create_That_Class();

            int previousCount = 0;

            Given("we want to fetch a spesific athlete class called G17");

            When("we fetch an existing class G17", () =>
            {
                previousCount = AthleteClassModel.GetAll().Count;
                athleteClass = AthleteClassModel.GetOrCreate("G17");
            });

            Then("we shold get an athlete class and no new DB rows should have been added", () =>
            {
                athleteClass.Name.ShouldBe("G17");
                AthleteClassModel.GetAll().Count.ShouldBe(previousCount);
            });
        }
Esempio n. 7
0
 public void TestSetup()
 {
     athleteClass = null;
 }
Esempio n. 8
0
        /// <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");
            }
        }