Example #1
0
        public void TestAthlete()
        {
            Athlete athlete = new Athlete();

            athlete.BibNumber = 21;
            athlete.Location  = 1234.04;
            DateTime testF = new DateTime(2017, 8, 10, 7, 10, 15);
            DateTime testS = new DateTime(2017, 8, 10, 5, 10, 20);

            Console.WriteLine(testF.Subtract(testS));
            athlete.prevRaceTime = testF;

            athlete.FirstName = "Ryan";
            athlete.status    = "dumb";

            Assert.AreEqual(athlete.BibNumber, 21);
            Assert.AreEqual(athlete.Location, 1234.04);

            Assert.AreEqual(athlete.FirstName, "Ryan");

            athlete.UpdateAthlete(1414.22, new DateTime(2017, 8, 10, 20, 10, 20), "STUmped");

            DateTime TestA = new DateTime(2017, 8, 10, 20, 10, 20);



            Assert.AreEqual(athlete.Location, 1414.22);
            Assert.AreEqual(athlete.currTime, TestA.Subtract(testF));
            Assert.AreEqual(athlete.status, "STUmped");
        }
        public IHttpActionResult UpdateUser(AthleteUser model)
        {
            User    userModel    = new User();
            Person  personModel  = new Person();
            Athlete athleteModel = new Athlete();

            #region Model to model - Person
            personModel.Email           = model.Email;
            personModel.Name            = model.Name;
            personModel.Sex             = Utility.GetSexID(model.Sex);
            personModel.BirthDate       = model.BirthDate.Date;
            personModel.CityID          = Utility.GetCityID(model.CityName, Utility.GetCountryID(model.CountryName));
            personModel.LastName        = model.LastName;
            personModel.TelephoneNumber = model.TelephoneNumber;
            #endregion

            #region Model to model - User
            userModel.Username = model.Username;
            userModel.Password = model.Password;
            userModel.Email    = model.Email;
            userModel.Role     = Utility.GetRoleID(model.Role);
            #endregion

            #region Model to model - Athlete
            athleteModel.Username  = model.Username;
            athleteModel.Weight    = model.Weight;
            athleteModel.Height    = model.Height;
            athleteModel.BikerType = Utility.GetBikerTypeID(model.BikerType);
            #endregion

            //Updating Values into Database
            personModel.UpdatePerson();
            var response = athleteModel.UpdateAthlete();

            if (response.IsComplete())
            {
                return(Ok(response.Body));
            }
            else
            {
                return(BadRequest(response.Message));
            }
        }