ITimeU.Controllers.AthleteController.Create C# (CSharp) Method

Create() public method

Creates the specified TXT first name.
public 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 ) : System.Web.Mvc.ActionResult
txtFirstName string First name.
txtLastName string Last name.
txtEmail string The email.
txtPostalAddress string Postal address.
txtPostalCode string The postal code.
txtCity string The city.
txtPhoneNumber string The phone number.
genderId string The gender id.
birthdateId string The birthdate id.
txtStartNumber string The start number.
clubId string The club id.
classId string The class id.
return System.Web.Mvc.ActionResult
        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");
            }
        }