//METODO PARA LEER EN LA BASE DE DATOS //LEER LISTADO DE TODOS LOS GIMNASIOS public static List <GymModel> ReadAllGyms() { var Connect = Db_Connection.ConexionSQL(); //ABRIMOS LA CONEXION Connect.Open(); //QUERY QUE SE EJECUTARA EN LA BASE DE DATOS var QueryC = new SqlCommand("EXECUTE ReadAllGyms;", Connect); //CREAMOS UN ADAPTADOR PARA LA CONSULTA SqlDataReader ResultSet = QueryC.ExecuteReader();; //INICIAMOS EL MODELO List <GymModel> resultGym = new List <GymModel>(); while (ResultSet.Read()) { GymModel InfoGym = new GymModel(); //LLENAMOS EL MODELO CON LOS DATOS EXTRAIDOS InfoGym.Id_Gym = int.Parse(ResultSet["Id_Gym"].ToString()); InfoGym.Gym_Campus = ResultSet["Gym_Campus"].ToString(); InfoGym.Gym_Address = ResultSet["Gym_Address"].ToString(); InfoGym.Gym_Phone = ResultSet["Gym_Phone"].ToString(); InfoGym.Gym_Income = int.Parse(ResultSet["Gym_Income"].ToString()); InfoGym.Gym_Email = ResultSet["Gym_Email"].ToString(); resultGym.Add(InfoGym); } Connect.Close(); return(resultGym); }
public static Gym mapToGym(GymModel source) { Gym target = new Gym(); target.GymId = source.GymId; target.GymName = source.GymName; target.GymBranch = source.GymBranch; return(target); }
public static GymModel[] mapToGymModel(Gym[] source) { GymModel[] targets = new GymModel[source.Length]; for (int i = 0; i < source.Length; i++) { targets[i] = mapToGymModel(source[i]); } return(targets); }
//LEER GIMNASIO SELECCIONADO public static Tuple <List <GymModel>, List <CoachModel>, List <ClassModel> > ReadOneGyms(int IdGym) { var Connect = Db_Connection.ConexionSQL(); //ABRIMOS LA CONEXION Connect.Open(); //QUERY QUE SE EJECUTARA EN LA BASE DE DATOS var QueryC = new SqlCommand("EXECUTE ReadOneGym '" + IdGym + "';", Connect); //CREAMOS UN ADAPTADOR PARA LA CONSULTA SqlDataReader ResultSet = QueryC.ExecuteReader();; //INICIAMOS EL MODELO List <GymModel> resultGym = new List <GymModel>(); List <CoachModel> resultCoach = new List <CoachModel>(); List <ClassModel> resultClass = new List <ClassModel>(); while (ResultSet.Read()) { GymModel InfoGym = new GymModel(); CoachModel InfoCoach = new CoachModel(); ClassModel InfoClass = new ClassModel(); //LLENAMOS EL MODELO CON LOS DATOS EXTRAIDOS InfoGym.Id_Gym = int.Parse(ResultSet["Id_Gym"].ToString()); InfoGym.Gym_Campus = ResultSet["Gym_Campus"].ToString(); InfoGym.Gym_Address = ResultSet["Gym_Address"].ToString(); InfoGym.Gym_Phone = ResultSet["Gym_Phone"].ToString(); InfoGym.Gym_Income = int.Parse(ResultSet["Gym_Income"].ToString()); InfoGym.Gym_Email = ResultSet["Gym_Email"].ToString(); InfoClass.Id_Class = int.Parse(ResultSet["Id_Class"].ToString()); InfoClass.Id_Coach_Class = int.Parse(ResultSet["Id_Coach_Class"].ToString()); InfoClass.Class_Name = ResultSet["Class_Name"].ToString(); InfoClass.Class_Limit = int.Parse(ResultSet["Class_Limit"].ToString()); InfoClass.Class_Inscribed = int.Parse(ResultSet["Class_Inscribed"].ToString()); InfoClass.Class_Hour = ResultSet["Class_Hour"].ToString(); InfoClass.Class_Duration = int.Parse(ResultSet["Class_Duration"].ToString()); InfoCoach.Id_Coach = int.Parse(ResultSet["Id_Coach"].ToString()); InfoCoach.Coach_Name = ResultSet["Coach_Name"].ToString(); resultGym.Add(InfoGym); resultClass.Add(InfoClass); resultCoach.Add(InfoCoach); } Connect.Close(); return(Tuple.Create(resultGym, resultCoach, resultClass)); }
public Gym EditGym(GymModel gymModel) { var gym = _dbContext.Gyms.Find(gymModel.Id); gym.Name = gymModel.Name; gym.Rating = gymModel.Rating; gym.ContactEmail = gymModel.ContactEmail; gym.Capacity = gymModel.Capacity; gym.Latitude = gymModel.Latitude; gym.Longitude = gymModel.Longitude; gym.StartOfWork = gymModel.StartOfWork; gym.EndOfWork = gymModel.EndOfWork; gym.AdminId = gymModel.Admin.Id; gym.AdressId = gymModel.Adress.Id; _dbContext.SaveChanges(); return(gym); }
public IActionResult CreateGym([FromBody] GymModel gymModel) { //map model to entity var gym = _mapper.Map <Gym>(gymModel); try { if (ModelState.IsValid) { var createResponse = _gymRepository.Create(gym); return(StatusCode(createResponse.StatusCode, gym)); } else { return(BadRequest()); } } catch (Exception) { return(StatusCode(500, "An unexpected internal server error has occured.")); } }
public ResponseResult AddGym(GymModel gymModel) { var gym = new Gym { Id = gymModel.Id, Name = gymModel.Name, Rating = gymModel.Rating, ContactEmail = gymModel.ContactEmail, Capacity = gymModel.Capacity, Latitude = gymModel.Latitude, Longitude = gymModel.Longitude, StartOfWork = gymModel.StartOfWork, EndOfWork = gymModel.EndOfWork, AdminId = gymModel.Admin.Id, AdressId = gymModel.Adress.Id, }; _dbContext.Gyms.Add(gym); _dbContext.SaveChanges(); return(ResponseResult.Ok); }
public WorkoutLogsController(GymModel context) { _context = context; }
public ExercisController(GymModel context) { _context = context; }
public UsersController(GymModel context) { _context = context; }
public ActionResult <GymModel> EditGym(GymModel model) { var gym = _gymRepository.EditGym(model); return(Ok(gym)); }
public ActionResult <string> AddGym(GymModel model) { var response = _gymRepository.AddGym(model); return(Ok()); }
public CategoriesController(GymModel context) { _context = context; }