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");
}
}