상속: System.Data.Objects.DataClasses.EntityObject
예제 #1
0
        public AthleteModel(Athlete athleteDb)
        {
            Id = athleteDb.ID;
            FirstName = athleteDb.FirstName;
            LastName = athleteDb.LastName;
            Birthday = athleteDb.Birthday;
            Email = athleteDb.Email;
            PostalAddress = athleteDb.PostalAddress;
            PostalCode = athleteDb.PostalCode;
            City = athleteDb.PostalPlace;
            PhoneNumber = athleteDb.Phone;
            Gender = athleteDb.Gender;
            Birthday = athleteDb.Birthday;

            if (athleteDb.Club != null)
                Club = ClubModel.GetOrCreate(athleteDb.Club.Name);
            if (athleteDb.AthleteClass != null)
                AthleteClass = AthleteClassModel.GetOrCreate(athleteDb.AthleteClass.Name);
            if (athleteDb.Startnumber != null)
                StartNumber = athleteDb.Startnumber;
        }
예제 #2
0
        private void updateProperties(Athlete athlete)
        {
            athlete.FirstName = FirstName;
            athlete.LastName = LastName;
            athlete.Birthday = Birthday;
            athlete.PostalAddress = PostalAddress;
            athlete.PostalCode = PostalCode;
            athlete.PostalPlace = City;
            athlete.Email = Email;
            athlete.Gender = Gender;
            athlete.Phone = PhoneNumber;
            athlete.IsDeleted = false;

            if (Club != null)
                athlete.ClubID = Club.SaveToDb();
            if (AthleteClass != null)
                athlete.ClassID = AthleteClass.SaveToDb();

            // athlete.AthleteClass = AthleteClass;
            athlete.Startnumber = StartNumber;
        }
예제 #3
0
        private int CreateDbEntity(Entities context)
        {
            Athlete athlete = new Athlete();
            updateProperties(athlete);
            context.Athletes.AddObject(athlete);
            context.SaveChanges();

            return athlete.ID;
        }
예제 #4
0
 private static Athlete createAthleteDbFrom(AthleteModel athlete)
 {
     Athlete athleteDb = new Athlete();
     athleteDb.FirstName = athlete.FirstName;
     athleteDb.LastName = athlete.LastName;
     return athleteDb;
 }
예제 #5
0
        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");
            }
        }
예제 #6
0
 /// <summary>
 /// Create a new Athlete object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static Athlete CreateAthlete(global::System.Int32 id)
 {
     Athlete athlete = new Athlete();
     athlete.ID = id;
     return athlete;
 }
예제 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Athletes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAthletes(Athlete athlete)
 {
     base.AddObject("Athletes", athlete);
 }