//Return list of coaches in the match public List <CoachModel> GetCoaches(XmlDocument doc) { var rtn = new List <CoachModel>(); var listCoaches = doc.GetElementsByTagName("CoachInfos"); foreach (XmlElement coach in listCoaches) { var tempCoach = new CoachModel(); var coachDataChildren = coach.ChildNodes; foreach (XmlElement c in coachDataChildren) { if (c.Name == "UserId") { tempCoach.UserId = c.FirstChild.Value; } else if (c.Name == "Login") { tempCoach.Login = c.FirstChild.Value; } else if (c.Name == "Slot") { tempCoach.Slot = Convert.ToInt16(c.FirstChild.Value); } } rtn.Add(tempCoach); } return(rtn); }
public CoachModel GetCoachModelSelectTeam(int teamID) { CoachModel coachModel = new CoachModel(); using (NetballEntities context = new NetballEntities()) { coachModel = context.Coaches .Include(c => c.Person) .Include(c => c.Team) .Where(c => c.TeamID == teamID) .Select(c => new CoachModel { personID = c.CoachID, teamID = c.TeamID, firstName = c.Person.FirstName, middleName = c.Person.MiddleName, lastName = c.Person.LastName, mobile = c.Person.Mobile, email = c.Person.Email, emergencyContact = c.Person.EmergencyContact, emergencyContactNo = c.Person.EmergencyContactNo, teamName = c.Team.TeamName, coachName = c.Person.FirstName + " " + c.Person.LastName, activeInd = c.ActiveInd }) .FirstOrDefault(); } return(coachModel); }
public async void UpdateCoach() { // Arrange. var coachModel = new CoachModel { FirstName = "Bezh", LastName = "Sulenin", Email = "*****@*****.**", MobileNumber = "06663342", TypeOfTraining = TypeOfTraining.Fitness }; var requestCoach = Map(coachModel); var requestJson = JsonConvert.SerializeObject(requestCoach); var coach = _context.Coaches.First(); var coachId = coach.Id; // Act. var response = await _client.PutAsync($"/api/Coach/{coachId}", new StringContent(requestJson, Encoding.UTF8, mediaType : "application/json")); // Assert. Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
public async void CreateCoach() { // Arrange. var coachModel = new CoachModel { FirstName = "Ivan", LastName = "Susanin", Email = "*****@*****.**", MobileNumber = "07773342", TypeOfTraining = TypeOfTraining.PowerLifting }; var requestJson = JsonConvert.SerializeObject(coachModel); var coach = Map(coachModel); // Act. var response = await _client.PostAsync( "/api/Coach", new StringContent( requestJson, Encoding.UTF8, mediaType : "application/json")); // Assert. var responseJson = await response.Content.ReadAsStringAsync(); var responseCoach = JsonConvert.DeserializeObject <Coach>(responseJson); Assert.Equal(HttpStatusCode.Created, response.StatusCode); Assert.Equal(coach, responseCoach); }
public async Task <ActionResult> AddTeam(CoachModel coachModel) { var teamsManager = new TeamsManager(ConfigurationManager.ConnectionStrings["WhosOnFirstDb"].ConnectionString); var teamExists = await teamsManager.ExistsAsync(coachModel.TeamName); if (!teamExists) { teamsManager.AddAsync(coachModel.TeamName); } var personManager = new PersonManager(ConfigurationManager.ConnectionStrings["WhosOnFirstDb"].ConnectionString); var person = new Person(); var userModel = Session["userModel"] as UserModel; person.PersonId = userModel.PersonId; person.FirstName = userModel.FirstName; person.LastName = userModel.LastName; person.PhoneNumber = userModel.PhoneNumber; person.EMail = userModel.EMail; person.IsPlayer = userModel.IsPlayer; person.IsCoach = userModel.IsCoach; person.IsValid = userModel.IsValid; person.IsAdmin = userModel.IsAdmin; var team = await teamsManager.RetrieveAsync(coachModel.TeamName); person.TeamId = team.TeamsId; personManager.Update(person); userModel.TeamId = team.TeamsId; Session["userModel"] = userModel; return(View(coachModel)); }
public CoachModel GetCoach(int coachID) { CoachModel coachModel = new CoachModel(); using (NetballEntities context = new NetballEntities()) { coachModel = context.Coaches .Include(c => c.Person) .Include(c => c.Team.Division) .Include(c => c.Team) .Select(c => new CoachModel { coachName = c.Person.FirstName + " " + c.Person.LastName, divisionID = c.Team.DivisionID, division = c.Team.Division.Division1, email = c.Person.Email, //emergencyContact = c. firstName = c.Person.FirstName, lastName = c.Person.LastName, middleName = c.Person.MiddleName, mobile = c.Person.Mobile, personID = c.CoachPersonID, teamID = c.TeamID, teamName = c.Team.TeamName }) .FirstOrDefault(); } return(coachModel); }
public ActionResult Edit(int personID) { CoachModel coachModel = new CoachModel(); coachModel = _coachModelSelectLogic.CoachModelSelect(personID); return(View(coachModel)); }
public void Update() { CoachDisplayModel exists = Coaches.Where(x => x.Id == SelectedCoach.Id).FirstOrDefault(); if (exists != null) { if (SelectedCoach != null && Coaches.Count > 0) { isUpdating = true; CoachModel e = new CoachModel { Id = SelectedCoach.Id, FirstName = _firstName, LastName = _lastName, Phone = _phone, Email = _email }; SqlDataAccess sql = new SqlDataAccess(); sql.UpdateData <CoachModel>("dbo.spCoach_Update", e, "ADBData"); msg = $"Coach ({SelectedCoach.FullName}) was successfully updated."; MessageBox.Show(msg, "Coach Updated"); Coaches = new BindingList <CoachDisplayModel>(GetAllCoaches()); Clear(); isUpdating = false; _events.PublishOnUIThread(new CoachChangedEvent()); } } }
public ActionResult Edit(CoachModel coachModel) { IPagedList <CoachModel> coachModelPagedList; Team team = new Team(); Team team1 = new Team(); if (_coachModelSelectLogic.CoachModelSelect(coachModel.personID) == null) { _insertCoachModelLogic.InsertCoachModel(coachModel); } if (coachModel.teamID > 0) { team = _teamParseLogic.ParseTeam(coachModel); team1 = _teamSelectLogic.GetTeam(coachModel.teamID); if (team1 != null) { team.TeamName = team1.TeamName; _teamUpdateLogic.TeamUpdateTransaction(team); } } coachModelPagedList = _coachModelPageListLogic.GetPagedList(1, 9); return(View("Index", coachModelPagedList)); }
public Database.Coach ParseCoach(CoachModel coachModel) { Database.Coach coach = new Database.Coach(); coach.CoachID = 0; coach.CoachPersonID = coachModel.personID; coach.TeamID = coachModel.teamID; return(coach); }
public ActionResult Delete(long id) { CoachModel ch = binder.coach.Find(id); binder.coach.Remove(ch); binder.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CoachIndex() { var userModel = Session["userModel"] as UserModel; var coachModel = new CoachModel(); coachModel.UserModel = userModel; return(View(coachModel)); }
public ActionResult Edit(CoachModel chm) { if (ModelState.IsValid) { binder.Entry(chm).State = System.Data.Entity.EntityState.Modified; binder.SaveChanges(); } return(RedirectToAction("Index")); }
public async Task StartCoach() { var coach = new CoachClient(isDebug: true); coach = await coach.Login("A2botdrxAn68aZh8Twwwt2sPBJdCfH3zO02QDMt0"); model = await coach.GetModelRemote("flowers", workers : 4); texture = image.texture as Texture2D; }
public ActionResult Edit(long id) { CoachModel cm = binder.coach.Find(id); if (cm == null) { return(HttpNotFound()); } return(View(cm)); }
async Task Init() { var coach = new CoachClient(isDebug: true); coach = await coach.Login("A2botdrxAn68aZh8Twwwt2sPBJdCfH3zO02QDMt0"); model = await coach.GetModelRemote("flowers", workers : 4); texture = image.texture as Texture2D; buttonText.text = "Using " + (sync ? "sync" : "async"); }
public Database.Team ParseTeam(CoachModel coachModel) { Database.Team team = new Database.Team(); team.TeamID = coachModel.teamID; team.TeamName = coachModel.teamName; team.DivisionID = coachModel.divisionID; team.CaptainID = coachModel.captainID; team.CoachID = coachModel.personID; team.TeamName = coachModel.teamName; return(team); }
async void Start() { var gpuName = SystemInfo.graphicsDeviceName; if (gpuName != null) { Debug.Log("GPU: " + gpuName); int gpuNumber = 0, idx = "Apple A".Length; while (idx < gpuName.Length && '0' <= gpuName[idx] && gpuName[idx] <= '9') { gpuNumber = gpuNumber * 10 + gpuName[idx++] - '0'; } Debug.Log("GPU COUNT: " + gpuNumber); } // Check for device cameras if (WebCamTexture.devices.Length == 0) { Debug.Log("No devices cameras found"); return; } // Get the device's cameras and create WebCamTextures with them #if UNITY_EDITOR if (WebCamTexture.devices.Any(d => d.name.Contains("Remote"))) { frontCameraDevice = WebCamTexture.devices.Last(d => d.name.Contains("Remote")); backCameraDevice = WebCamTexture.devices.First(d => d.name.Contains("Remote")); } else { frontCameraDevice = WebCamTexture.devices.Last(); backCameraDevice = WebCamTexture.devices.First(); } #else frontCameraDevice = WebCamTexture.devices.Last(); backCameraDevice = WebCamTexture.devices.First(); #endif frontCameraTexture = new WebCamTexture(frontCameraDevice.name); backCameraTexture = new WebCamTexture(backCameraDevice.name); // Set camera filter modes for a smoother looking image frontCameraTexture.filterMode = FilterMode.Trilinear; backCameraTexture.filterMode = FilterMode.Trilinear; // Set the camera to use by default SetActiveCamera(backCameraTexture); // Download Coach model var coach = await new CoachClient().Login("A2botdrxAn68aZh8Twwwt2sPBJdCfH3zO02QDMt0"); model = await coach.GetModelRemote("small_flowers", workers : this.Workers); }
private Coach Map(CoachModel coachModel) { var coach = new Coach { FirstName = coachModel.FirstName, LastName = coachModel.LastName, Email = coachModel.Email, MobileNumber = coachModel.MobileNumber, TypeOfTraining = coachModel.TypeOfTraining }; return(coach); }
//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 CoachModel ParseCoachModel(Person person) { CoachModel coachModel = new CoachModel(); coachModel.email = person.Email; coachModel.emergencyContact = person.EmergencyContact; coachModel.emergencyContactNo = person.EmergencyContactNo; coachModel.firstName = person.FirstName; coachModel.lastName = person.LastName; coachModel.middleName = person.MiddleName; coachModel.mobile = person.Mobile; coachModel.personID = person.PersonID; return(coachModel); }
public ActionResult Post(CoachModel coachModel) { if (!ModelState.IsValid) { return(BadRequest()); } var coach = Map(coachModel); _coachRepository.Add(coach); _fitnessDbContext.SaveChanges(); return(Created("", coach)); }
private CoachModel Map(Coach coach) { var coachModel = new CoachModel { Id = coach.Id, FirstName = coach.FirstName, LastName = coach.LastName, Email = coach.Email, MobileNumber = coach.MobileNumber, TypeOfTraining = coach.TypeOfTraining }; return(coachModel); }
public Person ParsePerson(CoachModel coachModel) { Person person = new Person(); person.Email = coachModel.email; person.EmergencyContact = coachModel.emergencyContact; person.EmergencyContactNo = coachModel.emergencyContactNo; person.FirstName = coachModel.firstName; person.LastName = coachModel.lastName; person.MiddleName = coachModel.middleName; person.Mobile = coachModel.mobile; person.PersonID = coachModel.personID; return(person); }
public bool CheckCoachModel(int coachPersonID, int teamID) { CoachModel coachModel = new CoachModel(); coachModel = _getCoachModelLogic.GetActiveCoachModel(teamID); if (coachModel == null) { return(false); } else { return(coachModel.personID == coachPersonID); } }
public ActionResult Save(CoachModel coach) { if (ModelState.IsValid) { try { binder.coach.Add(coach); binder.SaveChanges(); } catch (Exception e) { } } return(RedirectToAction("Index"));; }
public ActionResult Put(CoachModel coachModel, int id) { if (!ModelState.IsValid) { return(BadRequest()); } var coach = Map(coachModel); coach.Id = id; _coachRepository.Update(coach); _fitnessDbContext.SaveChanges(); return(Ok()); }
public void InsertCoachModel(CoachModel coachModel) { Person person; Database.Coach coach; person = _coachModelParseLogic.ParsePerson(coachModel); if (person.PersonID == 0) { _personInsert.PersonAdd(person); } else { _personUpdate.PersonUpdateTransaction(person); } coach = _coachModelParseLogic.ParseCoach(coachModel); _coachInsert.CoachAdd(coach); }
public CoachModel CoachModelSelect(int personID) { CoachModel coachModel = new CoachModel(); Database.Team team = new Database.Team(); using (NetballEntities context = new NetballEntities()) { coachModel = (from p in context.People where p.PersonID == personID from t in context.Teams.Where(t => t.CoachID == p.PersonID).DefaultIfEmpty() select new CoachModel { personID = p.PersonID, //teamID = t.TeamID, firstName = p.FirstName, middleName = p.MiddleName, lastName = p.LastName, mobile = p.Mobile, email = p.Email, emergencyContact = p.EmergencyContact, emergencyContactNo = p.EmergencyContactNo, teamName = t.TeamName, coachName = p.FirstName + " " + p.LastName, captainID = t.CaptainID, divisionID = t.DivisionID }) .FirstOrDefault(); } if (!string.IsNullOrEmpty(coachModel.teamName)) { team = _teamSelectLogic.GetTeam(coachModel.teamName); if (team != null) { coachModel.teamID = team.TeamID; } } return(coachModel); }
public async void CreateCoachWithNotValidData() { // Arrange. var coachModel = new CoachModel { FirstName = "Khan", LastName = "Sirofimovich", Email = "*****@*****.**", MobileNumber = "0000000", TypeOfTraining = (TypeOfTraining)10 }; var requestJson = JsonConvert.SerializeObject(coachModel); // Act. var response = await _client.PostAsync( "/api/Coach", new StringContent(requestJson, Encoding.UTF8, mediaType : "application/json")); // Assert. Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }