public IHttpActionResult RegisterAthlete(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; personModel.CityID = Utility.GetCityID(model.CityName, Utility.GetCountryID(model.CountryName)); personModel.LastName = model.LastName; personModel.TelephoneNumber = model.TelephoneNumber; #endregion if (model.Role != "Atleta") { return(BadRequest("Esta funciĆ³n es para atletas.")); } #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); athleteModel.Bike = model.Bike; #endregion //Adding values to Databases personModel.AddPerson(); var response = userModel.AddUser(); athleteModel.AddAthlete(); if (response.IsComplete()) { return(Ok(response.Body)); } else { return(BadRequest(response.Message)); } }