Пример #1
0
        //[HttpGet]
        //public string Greet()
        //{
        //    return "BJ ";
        //}
        //[HttpGet]
        //public string Greet2(bool showDate)
        //{
        //    return "BJ2 " + DateTime.Now.ToLongDateString();
        //}
        //public IHttpActionResult GetProduct(int id)
        //{
        //    if (id == 1)
        //    {
        //        return Ok("Product Found");
        //    }
        //    else
        //    {
        //        return NotFound();
        //    }
        //}
        public IHttpActionResult GetCoach(Coach c)
        {
            /*
             * Fiddler REquest
             * http://localhost:56372/api/test
             *
             * User-Agent: Fiddler
                Host: localhost:56372
                Content-Length: 22
                Accept: application/json
                Content-Type: application/json

            Body
            {"FirstName" : "Bill"}

             */

            if (c.FirstName=="Bill")
            {
                return Ok(c);
            }
            else
            {
                return NotFound();
            }
        }
Пример #2
0
 protected override Coach ReadCoach()
 {
     Coach coach = new Coach(sr.ReadInt32(), (CoachType)sr.ReadByte());
     int count = sr.ReadInt32();
     for (int i = 0; i < count; i++)
         coach.AddRoom(ReadRoom());
     return coach;
 }
Пример #3
0
 protected override Coach ReadCoach()
 {
     Coach coach = new Coach(Int32.Parse(sr.ReadLine()), (CoachType)Int32.Parse(sr.ReadLine()));
     int count = Int32.Parse(sr.ReadLine());
     for (int i = 0; i < count; i++)
         coach.AddRoom(ReadRoom());
     return coach;
 }
Пример #4
0
 protected override void WriteCoach(Coach coach)
 {
     sw.Write(coach.Id);
     sw.Write((byte)coach.Type);
     sw.Write(coach.Rooms.Count);
     foreach (Room room in coach)
         WriteRoom(room);
 }
 public void InsertOrUpdate(Coach coach)
 {
     if (coach.CoachId == default(int)) {
         // New entity
         context.Coaches.Add(coach);
     } else {
         // Existing entity
         context.Coaches.Attach(coach);
         context.Entry(coach).State = EntityState.Modified;
     }
 }
Пример #6
0
 public ActionResult Edit(Coach coach)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("Staff"));
     }
     if (ModelState.IsValid)
     {
         db.Entry(coach).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(coach));
 }
Пример #7
0
        //
        // GET: /Coaches/Edit/5

        public ActionResult Edit(int id = 0)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Staff"));
            }
            Coach coach = db.Coaches.Find(id);

            if (coach == null)
            {
                return(HttpNotFound());
            }
            return(View(coach));
        }
Пример #8
0
        public IHttpActionResult DeleteCoach(int id)
        {
            Coach coach = db.Coaches.Find(id);

            if (coach == null)
            {
                return(NotFound());
            }

            db.Coaches.Remove(coach);
            db.SaveChanges();

            return(Ok(coach));
        }
Пример #9
0
 // ----------------- TRAINING SCHEDULING ----------------------
 public void TrainingScheduling(List <Student> students, Training training, Coach coach)
 {
     foreach (Student student in students)
     {
         _studentTrainingRepo.Add(new STUDENT_TRAINING
         {
             STUDENT = new STUDENT
             {
                 DISCOUNT    = (Decimal)student.Discount,
                 PAYMENTTYPE = student.PaymentType,
                 PERSON      = new PERSON
                 {
                     FIRSTNAME = student.FirstName,
                     LASTNAME  = student.LastName,
                     EMAIL     = student.Email,
                     TELEPHONE = student.Telephone
                 }
             },
             TRAINING = new TRAINING
             {
                 TRAINING_INTERNAL_ID = training.Training_Internal_Id,
                 DURATION             = training.Duration,
                 NOTES     = training.Notes,
                 STARTDATE = DateTime.ParseExact(training.StartDate, "yyyy-MM-dd",
                                                 System.Globalization.CultureInfo.InvariantCulture),
                 TRAININGTHEME = training.TrainingTheme,
                 TRAININGTYPE  = training.TrainingType,
                 COACH         = new COACH
                 {
                     PAYMENTRATE       = coach.PaymentRate,
                     PAYOFFRATE        = coach.PayOffRate,
                     COACH_INTERNAL_ID = coach.Coach_Internal_Id,
                     PERSON            = new PERSON
                     {
                         FIRSTNAME = coach.FirstName,
                         LASTNAME  = coach.LastName,
                         EMAIL     = coach.Email,
                         TELEPHONE = coach.Telephone
                     }
                 }
             },
             AMOUNT          = 100,
             PAYMENTTYPE     = "mesecno",
             RELATIONSHIP    = "something",
             TRAININGQUALITY = "something"
         });
     }
     _unitOfWork.Commit();
 }
Пример #10
0
        private void addCoachButton_Click(object sender, EventArgs e)
        {
            coachFirstname = addCoachFirstNameTextBox.Text;
            coachLastname  = addCoachLastNameTextBox.Text;
            addCoachColour.Text.Split(' ');

            var checkCharFirstName = addCoachFirstNameTextBox.Text.IndexOfAny(disallowedCharacters) != -1;
            var checkCharLastName  = addCoachLastNameTextBox.Text.IndexOfAny(disallowedCharacters) != -1;

            if (checkCharFirstName != true && checkCharLastName != true)
            {
                if (coachFirstname.Length > 1 && coachLastname.Length > 1)
                {
                    using (var db = new DatabaseContext())
                    {
                        Coach c = new Coach();
                        c.player           = new Player();
                        c.player.Firstname = coachFirstname;
                        c.player.Lastname  = coachLastname;
                        c.CoachRed         = colorDialog1.Color.R;
                        c.CoachGreen       = colorDialog1.Color.G;
                        c.CoachBlue        = colorDialog1.Color.B;


                        if (addCoachColour.Text == "(Click this box)" || addCoachColour.Text == "255 255 255")
                        {
                            MessageBox.Show("Please select a valid colour (white not allowed)");
                        }
                        else
                        {
                            db.Coach.Add(c);
                            db.SaveChanges();
                            MessageBox.Show("Coach successfully added");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Incorrect name length");
                }
            }
            else
            {
                MessageBox.Show("Invalid character in coach names");
            }
            populateDropDownMenus();
            addCustomerSource();
            //if (addCoachFirstNameTextBox.Text.Contains(disallowedCharacters.Any(x => x == disallowedCharacters[i])))
        }
Пример #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            //firstname = addCoachFirstNameTextBox.Text.ToString();
            //lastname = addCoachLastNameTextBox.Text.ToString();
            //CoachColorHexValue = comboBox1.Text.ToString();

            //using (var db = new DatabaseContext())
            //{
            //    if (!checkIfColourTaken(CoachColorHexValue))
            //    {
            //        Coach c = new Coach();
            //        c.player = new Player();
            //        c.player.Firstname = firstname;
            //        c.player.Lastname = lastname;
            //        c.CoachColor = CoachColorHexValue;

            //        db.Coach.Add(c);
            //        db.SaveChanges();
            //    }
            //    else
            //    {
            //        MessageBox.Show("Colour already taken!");
            //    }
            //}
            coachFirstname = addCoachFirstNameTextBox.Text;
            coachLastname  = addCoachLastNameTextBox.Text;
            addCoachColour.Text.Split(' ');

            using (var db = new DatabaseContext())
            {
                Coach c = new Coach();
                c.player           = new Player();
                c.player.Firstname = coachFirstname;
                c.player.Lastname  = coachLastname;
                c.CoachRed         = colorDialog1.Color.R;
                c.CoachGreen       = colorDialog1.Color.G;
                c.CoachBlue        = colorDialog1.Color.B;


                if (addCoachColour.Text == "")
                {
                    MessageBox.Show("Please select a colour");
                }

                db.Coach.Add(c);
                db.SaveChanges();
                MessageBox.Show("Coach successfully added");
            }
        }
Пример #12
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public JsonResult Update(Coach entity)
 {
     ModelState.Remove("CreatedTime");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("IsDelete");
     if (ModelState.IsValid)
     {
         var result = ICoachService.UpdateCoach(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }
Пример #13
0
        static void Main(string[] args)
        {
            Coach  therapy  = new Coach();
            Coach  tobiamus = new Coach();
            Player josh     = new Player();
            Player tom      = new Player();
            Player jake     = new Player();
            Player joe      = new Player();
            Player ben      = new Player();

            MethodExample methodExample = new MethodExample();
            string        myString      = methodExample.ReverseString("Reverse me");

            Console.WriteLine(myString);
        }
Пример #14
0
        public ActionResult Create(Coach coach)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", coach));
            }
            else
            {
                ApplicationDbContext db = new ApplicationDbContext();
                db.Coachs.Add(coach);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
Пример #15
0
        public SurveyListPage(Coach coach, Action <Survey, INavigation> onSelect)
        {
            this.coach = coach;

            Title = "Feedback";

            surveyList             = new ListView();
            surveyList.ItemTapped += (sender, args) =>
            {
                var survey = ((Survey)args.Item);
                onSelect(survey, Navigation);
            };

            Content = surveyList;
        }
Пример #16
0
        public void DeclareCoach_Saveobject_Coach()
        {
            _expectedCoach = new Coach()
            {
                Name = "",
                TeamId = _teamid,
                PhoneNumber = "",
                Mail = ""
            };

             _target.DeclareCoach("", _teamid, "", "");

            _stubPersistentService.AssertWasCalled(x=>x.
                Saveobject(Arg<Coach>.Matches(actualcoach=>CheckCoach(actualcoach,_expectedCoach)), Arg<string>.Is.Same("coach.json")));
        }
Пример #17
0
        private void LogIn()
        {
            do
            {
                var credentials = new Credentials()
                {
                    Email    = _ioHelper.GetStringFromUser("Enter your email: "),
                    Password = _ioHelper.GetStringFromUser("Enter your password: "),
                };

                _loggedCoach = LogCoach(credentials);
            }while (_loggedCoach == null);

            PrintCoachMenu();
        }
Пример #18
0
        public void DeclareCoach_CheckArguments_Coach()
        {
            _expectedCoach = new Coach()
            {
               Name = "",
               TeamId = _teamid,
               PhoneNumber= "",
               Mail = ""
            };

            var actual = _target.DeclareCoach("", _teamid, "", "");
            Assert.AreEqual(_expectedCoach.Name, actual.Name);
            Assert.AreEqual(_expectedCoach.PhoneNumber, actual.PhoneNumber);
            Assert.AreEqual(_expectedCoach.Mail, actual.Mail);
        }
Пример #19
0
 // ---------------------------------------------------------
 // Combobox Coach selection changed eventhandler
 // ---------------------------------------------------------
 private void cbCoachName_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         Coach selectedItem = (Coach)cbCoachName.SelectedItem;
         if (selectedItem != null)
         {
             tbCoachId.Text = selectedItem.idCoach.ToString();       // change the coachId number in the textbox right side
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Something isn't right...", "Oops!", MessageBoxButton.OK, MessageBoxImage.Exclamation);
     }
 }
        public IActionResult AddProfile()
        {
            var   currentUserId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            Coach coach         = new Coach();

            if (db.Coaches.Any(i => i.UserId == currentUserId))
            {
                coach = db.Coaches.FirstOrDefault(i => i.UserId == currentUserId);
            }
            else
            {
                coach.UserId = currentUserId;
            }
            return(View(coach));
        }
Пример #21
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Coach = await _context.Coaches.FirstOrDefaultAsync(m => m.ID == id);

            if (Coach == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #22
0
        public void DeclareCoach_Saveobject_Coach()
        {
            _expectedCoach = new Coach()
            {
                Name        = "",
                TeamId      = _teamid,
                PhoneNumber = "",
                Mail        = ""
            };

            _target.DeclareCoach("", _teamid, "", "");

            _stubPersistentService.AssertWasCalled(x => x.
                                                   Saveobject(Arg <Coach> .Matches(actualcoach => CheckCoach(actualcoach, _expectedCoach)), Arg <string> .Is.Same("coach.json")));
        }
Пример #23
0
        public Coach GetMemberInfo(string MemberId)
        {
            Coach coach = strategy.GetMemberInfo(MemberId);

            coach.Area              = strategy.GetUserArea(MemberId);
            coach.CourseId          = strategy.GetCoachCourse(MemberId).Select(c => c.CourseId).ToList();
            coach.TrainingProgramId = strategy.GetTrainingProgram(MemberId).Select(c => c.TrainingProgramId).ToList();
            coach.Course            = strategy.GetCoachCourse(MemberId).Select(c => c.Course).ToList();
            coach.TrainingProgram   = strategy.GetTrainingProgram(MemberId).Select(c => c.TrainingProgram).ToList();
            coach.License           = strategy.GetCoachLicense(MemberId);
            coach.Experience        = strategy.GetCoachExperience(MemberId);
            coach.Competiton        = strategy.GetCoachCompetiton(MemberId);
            coach.Image             = strategy.GetUserImage(MemberId); //圖片檔名
            return(coach);
        }
Пример #24
0
        public void AssignedClubToCoachGivesRightClubObject()
        {
            //arrange
            Club.count = 0;
            Coach aCoach = new Coach("dave", new DateTime(), new Address(), 1234567890);
            Club  aClub  = new Club();

            //act
            aClub.AddCoach(aCoach);
            Club expected = aClub;
            //Assert
            Club actual = aCoach.AssignedClubToCoach;

            Assert.AreEqual(expected, actual);
        }
Пример #25
0
        // GET: Coach/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Coach coach = db.Coachs.Include(c => c.FilePaths).SingleOrDefault(c => c.CoachID == id);

            if (coach == null)
            {
                return(HttpNotFound());
            }
            return(View(coach));
        }
Пример #26
0
        public static bool Update(Coach e)
        {
            DB     db    = DB.getDB(file);
            string query = @"UPDATE Coach set coachName = @coachName, coachAge = @coachAge, coachCC = @coachCC
                            WHERE idCoach = @idCoach";
            Dictionary <string, object> parms = new Dictionary <string, object>();

            parms.Add("@idCoach", e.Id);
            parms.Add("@coachName", e.Name);
            parms.Add("@coachAge", e.Age);
            parms.Add("@coachCC", e.CC);
            bool res = db.NonQuery(query, parms);

            return(res);
        }
Пример #27
0
        public async Task <User> GetUserFromCoachAsync(string currentUserId, string coachId)
        {
            Coach coach = await GetCoachFromCoachId(coachId);

            if (coach == null)
            {
                throw new Exception("The coach doesn't exist");
            }
            if (coach.UserId != currentUserId)
            {
                throw new UnauthorizedAccessException("You are not the user corresponding this coach");
            }

            return(await GetUserFromId(coach.UserId));
        }
Пример #28
0
        public Coachs()
        {
            InitializeComponent();
            UserErrors = new BindingList <string>();
            activities = new BindingList <string>();

            currentCoach  = new Coach();
            currentSeance = new Seance();
            // Disable Code Adhérant
            CodeAdhTB.Enabled    = false;
            CodeAdhIcon.Enabled  = false;
            CodeAdhPanel.Enabled = false;
            // Initialize Sexe CB
            SexeCB.SelectedIndex = 0;
        }
Пример #29
0
 private void gridViewTimes_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         timeID = "" + gridViewTimes.SelectedRows[0].Cells[0].Value;
         getData(Coach.getCoachesByRouteAndTimeIDAsSqlDataAdapter(int.Parse(routeID), int.Parse(timeID)), bindingSourceCoaches);
     }
     catch (ArgumentOutOfRangeException aoorex)
     {
     }
     catch (Exception ex)
     {
         MessageBox.Show("Probe 3: " + ex);
     }
 }
Пример #30
0
        public void CoachIsAssignedToClubWorksCorrect()
        {
            //arrange
            Club.count = 0;
            Coach aCoach = new Coach("dave", new DateTime(), new Address(), 1234567890);
            Club  aClub  = new Club();

            //act
            aClub.AddCoach(aCoach);
            bool expected = true;
            //Assert
            bool actual = aCoach.CoachIsAssignedToClub;

            Assert.AreEqual(expected, actual);
        }
Пример #31
0
        public async Task <IActionResult> CreateCoach([FromBody] CreateCoachCommand command)
        {
            var coach = new Coach(command.Name, command.Email, command.Age, command.PhoneNum);

            _coachRepository.Add(coach);
            try
            {
                await _coachRepository.CommitAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok());
        }
Пример #32
0
        // GET: Coaches/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Coach coach = db.Coach.Find(id);

            if (coach == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SwimmingPoolID = new SelectList(db.SwimmingPool, "Id", "Name", coach.SwimmingPoolID);
            return(View(coach));
        }
Пример #33
0
        // GET: Coach/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Coach coach = db.coaches.Find(id);

            if (coach == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CoachId = new SelectList(db.team, "TeamId", "Name", coach.CoachId);
            return(View(coach));
        }
Пример #34
0
        public Coach InsertCoach(Coach coach)
        {
            var dbCoach = new Coach
            {
                FirstName   = coach.FirstName,
                Surname     = coach.Surname,
                Email       = coach.Email,
                PhoneNumber = coach.PhoneNumber,
                Id          = _nextId
            };

            _coachesDictionary[dbCoach.Id] = dbCoach;
            _nextId++;
            return(dbCoach);
        }
Пример #35
0
        public ActionResult PasswordRecovery(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Coach coach = db.Coaches.Find(id);

            if (coach == null)
            {
                return(HttpNotFound());
            }
            return(View(coach));
        }
Пример #36
0
        public void AddSwimmerMethodGivingExceptionWhenCoachIsNotRegisteredToTheSameClubAsThatOfSwimmer()
        {
            //arrange
            Club.count = 0;
            Swimmer aSwimmer = new Swimmer();
            Club    aClub    = new Club();
            Coach   aCoach   = new Coach("dave", new DateTime(), new Address(), 1234567890);

            //act
            aClub.AddCoach(aCoach);
            //aClub.AddSwimmer(aSwimmer);
            aCoach.AddSwimmer(aSwimmer);
            Swimmer expected = aSwimmer;
            //Assert
        }
Пример #37
0
        public static bool Delete(Coach e)
        {
            DB     db    = DB.getDB(file);
            string query = @"DELETE FROM Coach WHERE coachCC = @coachCC";
            Dictionary <string, object> parms = new Dictionary <string, object>();

            parms.Add("@coachCC", e.CC);
            bool res = db.NonQuery(query, parms);

            if (res)
            {
                e.Id = db.LastId();
            }
            return(res);
        }
Пример #38
0
        public void SelectPlayerForMatch()
        {
            //Setup preconditions
            var coach = new Coach();
            var player = new Player();

            //Execute the code to be tested
            coach.SelectPlayerForMatch(player);

            //Assert on the expected results
            Assert.IsTrue(player.IsSelected);
            Assert.AreEqual(100, player.Happiness);

            Assert.AreEqual(1, coach.Players.Count);
            Assert.AreEqual(player, coach.Players.ElementAt(0));
        }
Пример #39
0
        public Coach DeclareCoach(string name, Guid teamId,  string phonenumber, string mail)
        {
            var coach = new Coach()
            {
                Id = Guid.NewGuid(),
                Name = name,
                TeamId = Guid.NewGuid(),
                PhoneNumber = phonenumber,
                Mail = mail,
                Date = DateTime.Now

            };

            _persistentService.Saveobject(coach, "coach.json");

            return coach;
        }
Пример #40
0
        public void CreateCoachTest()
        {
            var context = new Core.Data.CSBCDbContext();

            var rep = new CoachRepository(context);
            Debug.Assert(context.People != null, "context.People != null");
            var coach = new Coach
            {
                CompanyID = 1,
                PeopleID = context.People.FirstOrDefault().PeopleID,
                SeasonID = context.Seasons.First(s => s.CurrentSeason == true).SeasonID,
                CoachPhone = "999-000-9090"
            };
            var i = rep.Insert(coach);

            Assert.IsTrue(coach.CoachID > 0);
        }
Пример #41
0
        public void SelectPlayerForMatch()
        {
            // Setup preconditions including the setup of mock objects
            var coach = new Coach();
            var playerMock = new Mock<IPlayer>();

            //Inject mocked dependencies
            //Execute the code to be tested
            coach.SelectPlayerForMatch(playerMock.Object);

            //Assert on the expected results
            Assert.AreEqual(1, coach.Players.Count);
            Assert.AreEqual(playerMock.Object, coach.Players[0]);

            // Verify that the mock object was called the expected number of times and with the expected parameters
            playerMock.Verify(x => x.Selected(), Times.Once);
        }
Пример #42
0
        public Coach GetCoach(string firstName, string secondName)
        {
            var aspNetUserFromDb = context.AspNetUsers.First(x => x.FirstName == firstName && x.SecondName==secondName);

            Coach coach = new Coach()
            {
                FirstName = aspNetUserFromDb.FirstName,
                SecondName = aspNetUserFromDb.SecondName,
                Address_AddressLine1 = aspNetUserFromDb.Address_AddressLine1,
                Address_AddressLine2 = aspNetUserFromDb.Address_AddressLine2,
                Address_AddressLine3 = aspNetUserFromDb.Address_AddressLine3,
                Address_City = aspNetUserFromDb.Address_City,
                Address_Country = aspNetUserFromDb.Address_Country,
                Address_County = aspNetUserFromDb.Address_County,
                Address_PostalCode = aspNetUserFromDb.Address_PostalCode,
                Email = aspNetUserFromDb.Email,
                PhoneNumber = aspNetUserFromDb.PhoneNumber,
                TemplateID = aspNetUserFromDb.TemplateID,
                ProfileImage = aspNetUserFromDb.ProfileImage
            };
            return coach;
        }
    public void Refresh_panel()
    {
        translations = GlobalVariables.translations;

        //Translations
        heading_title.GetComponent<Text> ().text= translations.getString ("activities");

        user = GlobalVariables.user;
        coach = _database.getCoach (user.id);

        for (int i = GUI_parent.transform.childCount - 1; i >= 0; i--)
        {
            // objectA is not the attached GameObject, so you can do all your checks with it.
            GameObject objectA = GUI_parent.transform.GetChild(i).gameObject;
            objectA.transform.parent = null;
            // Optionally destroy the objectA if not longer needed
        }

        List<Activity> activities = coach.activities;
        itemCount = activities.Count;
        columnCount = 1;

        RectTransform rowRectTransform = itemPrefab.GetComponent<RectTransform>();
        RectTransform containerRectTransform = GUI_parent.GetComponent<RectTransform>();

        //calculate the width and height of each child item.
        float width = containerRectTransform.rect.width / columnCount;
        float ratio = 1 /*width / rowRectTransform.rect.width*/;
        float height = rowRectTransform.rect.height * ratio;

        int rowCount = itemCount / columnCount;
        if (rowCount == 0)
            rowCount = 1;
        if (itemCount % rowCount > 0)
            rowCount++;

        //adjust the height of the container so that it will just barely fit all its children
        float scrollHeight = height * rowCount;
        float scrollWidth = width * itemCount;
        containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -scrollHeight);
        containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, 0);

        int j = 0;

        for (int i = 0; i < itemCount; i++)
        {
            //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns
            if (i % columnCount == 0)
                j++;

            Activity activity = activities[i];
            int id = activity.id;
            string datetime = activity.datetime;
            int skill_id = activity.skill_id;
            int statistics_id = activity.statistics_id;
            int player_id = activity.player_id;
            int team_id = activity.team_id;
            Player player = _database.getPlayer(player_id);
            Team team = _database.getTeam(team_id);
            int discipline_id = team.discipline_id;

            List<Feedback> feedbacks = activity.feedbacks;
            if (activity.feedbacks.Count==0)
            {
                GlobalVariables.selected_feedback_id = 0;
                GameObject.Find("cca_button_edit_feedback").GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("add_feedback");
            }
            else
            {
                GlobalVariables.selected_feedback_id = feedbacks[0].id;
                GameObject.Find("cca_feedback").GetComponent<Text> ().text=activity.feedbacks[0].text;
                GameObject.Find("cca_button_edit_feedback").GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("edit_feedback");
            }

            GameObject.Find("cca_button_view_activity").GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("view");
            GameObject.Find("cca_label_skill").GetComponent<Text> ().text=translations.getString ("skill");
            GameObject.Find("cca_label_score").GetComponent<Text> ().text=translations.getString ("score");
            GameObject.Find("cca_label_feedback").GetComponent<Text> ().text=translations.getString ("feedback");
            GameObject.Find("cca_label_team").GetComponent<Text> ().text=translations.getString ("team");
            GameObject.Find("cca_label_club").GetComponent<Text> ().text=translations.getString ("club");

            string photo = player.photo;
            string player_name = player.name;
            string player_surname = player.surname;
            int club_id = player.club_id;

            Skill skill = _database.getSkill(skill_id);
            string skill_name = skill.name;

            Statistics statistics = _database.getStatistics(statistics_id);
            double score = statistics.overall_score;

            GameObject.Find("cca_label_player_name").GetComponent<Text> ().text=player_name+" "+player_surname;
            GameObject.Find("cca_skill").GetComponent<Text> ().text=skill_name;

            GameObject.Find("cca_score").GetComponent<Text> ().text=score.ToString();
            GameObject.Find("cca_label_datetime").GetComponent<Text> ().text=datetime;

            string[] parts = photo.Split('.');
            photo = "images/"+parts[0];

            Texture image = (Texture)Resources.Load(photo, typeof(Texture));
            GameObject.Find("cca_image").GetComponent<RawImage> ().texture=image;

            GameObject newItem = Instantiate(itemPrefab) as GameObject;
            newItem.name = id.ToString();
            newItem.transform.parent = GUI_parent.transform;
            newItem.transform.localScale = Vector3.one;
            //Debug.Log("textos dentro: "+newItem.GetComponentsInChildren<Button>().Length.ToString());
            Button[] buttons = newItem.GetComponentsInChildren<Button>();
            foreach (Button button in buttons)
            {

                if (button.name=="cca_button_view_activity")
                {
                    button.onClick.AddListener(() => {
                        GlobalVariables.selected_activity_id = id;
                        GlobalVariables.selected_player_id = player_id;
                        GlobalVariables.selected_club_id = club_id;
                        GlobalVariables.selected_team_id = team_id;
                        GlobalVariables.selected_discipline_id = discipline_id;
                        Debug.Log("activity id: "+id);

                        coach_and_train_scenario.GoToActivity();

                    });
                }

                else if (button.name=="cca_button_edit_feedback")
                {

                    button.onClick.AddListener(() => {
                        GlobalVariables.selected_activity_id = id;
                        GlobalVariables.selected_player_id = player_id;
                        GlobalVariables.selected_club_id = club_id;
                        GlobalVariables.selected_team_id = team_id;
                        GlobalVariables.selected_discipline_id = discipline_id;
                        Debug.Log("feedback id: "+id);

                        coach_and_train_scenario.GoToFeedback();

                    });
                }

            }

            Debug.Log (newItem.name);

            //move and size the new item
            RectTransform rectTransform = newItem.GetComponent<RectTransform>();

            float x = -containerRectTransform.rect.width / 2 + width * (i % columnCount);
            float y = containerRectTransform.rect.height / 2 - height * j;
            rectTransform.offsetMin = new Vector2(x, y);

            x = rectTransform.offsetMin.x + width;
            y = rectTransform.offsetMin.y + height;
            rectTransform.offsetMax = new Vector2(x, y);

        }

        /*foreach (Activity activity in coach.activities)
        {
            string datetime = activity.datetime;
            int player_id = activity.player_id;
            int skill_id = activity.skill_id;
            int statistics_id = activity.statistics_id;

            List<Feedback> feedbacks = activity.feedbacks;

            Player player = _database.getPlayer(player_id);
            string photo = player.photo;
            string player_name = player.name;
            string player_surname = player.surname;

            Skill skill = _database.getSkill(skill_id);
            string skill_name = skill.name;
            Team team=new Team();

            foreach (Team tt in player.teams)
            {
                Debug.Log("team discipline:"+tt.discipline_id+",skill discipline "+skill.discipline_id );
                if (tt.discipline_id == skill.discipline_id)
                {
                    team = _database.getTeam(tt.id);
                    Debug.Log(tt.id+" "+tt.name+" "+tt.discipline_id );
                }
            }

            string team_name = team.name;
            Club club = _database.getClub(player.club_id);
            string club_name = club.name;
            Statistics statistics = _database.getStatistics(statistics_id);
            double score = statistics.overall_score;

        }*/
    }
Пример #44
0
        public ActionResult Index(CoachViewModel vm, HttpPostedFileBase Image1)
        {
            //Session["vm"] = vm;

            if (Image1 != null && Image1.ContentLength > 0)
            {

                //var fileName = Path.GetFileName(Image1.FileName);
                var path = Server.MapPath("~/content/images/uploads");
                //System.IO.File.Delete(path + "/Coach.jpg");
                if (System.IO.File.Exists(path + "/" + vm.FirstName + vm.SecondName + ".jpg"))
                    {
                    System.IO.File.Delete(path + "/" + vm.FirstName + vm.SecondName + ".jpg");
                }
                /*
                FileInfo temp = new FileInfo(path + "/Coach.jpg");
                if (temp.Exists) temp.Delete();
                */

                Image1.SaveAs(path + "/" + vm.FirstName + vm.SecondName + ".jpg");
                vm.Image1Name = vm.FirstName + vm.SecondName + ".jpg";
            }

            Coach c = new Coach()
            {
                 Id=vm.ID,
                FirstName = vm.FirstName,
                 SecondName=vm.SecondName,
                  Email=vm.Email,
                  PhoneNumber = vm.Phone,
                  TemplateID = vm.TemplateId,
                   ProfileImage= vm.FirstName + vm.SecondName + ".jpg"

            };

            vm.Image1Name = vm.FirstName + vm.SecondName + ".jpg";
            //vm.Image1Path = Server.MapPath("~/content/images/uploads") + "/" + vm.FirstName + vm.SecondName + ".jpg";

            vm.Image1Path = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/content/images/uploads/" + vm.Image1Name;

            repository.Save(c);

            return View(vm);
        }
Пример #45
0
        public Coach GetCoachById(string userId)
        {
            var aspNetUserFromDb = context.AspNetUsers.First(x => x.Id == userId);

            Coach coach = new Coach() {
                FirstName = aspNetUserFromDb.FirstName,
                SecondName = aspNetUserFromDb.SecondName,
                 Address_AddressLine1 = aspNetUserFromDb.Address_AddressLine1,
                 Address_AddressLine2 = aspNetUserFromDb.Address_AddressLine2,
                 Address_AddressLine3 = aspNetUserFromDb.Address_AddressLine3,
                  Address_City=aspNetUserFromDb.Address_City,
                  Address_Country=aspNetUserFromDb.Address_Country,
                  Address_County=aspNetUserFromDb.Address_County,
                  Address_PostalCode=aspNetUserFromDb.Address_PostalCode,
                  Email=aspNetUserFromDb.Email,
                  PhoneNumber = aspNetUserFromDb.PhoneNumber,
                  TemplateID=aspNetUserFromDb.TemplateID,
                  ProfileImage=aspNetUserFromDb.ProfileImage,
                  Subscriber=aspNetUserFromDb.Subscriber,
                  SubscriptionEnd=aspNetUserFromDb.SubscriptionEnd
            };
            return coach;
        }
Пример #46
0
        public void Save(Coach coach)
        {
            var target = context.AspNetUsers.Where(x => x.Id == coach.Id).FirstOrDefault();
            target.FirstName = coach.FirstName;
            target.SecondName = coach.SecondName;
            target.Email = coach.Email;
            target.PhoneNumber = coach.PhoneNumber;
            target.TemplateID = coach.TemplateID;
            target.ProfileImage = coach.ProfileImage;

            context.SaveChanges();
        }
Пример #47
0
 private Coach CreateCoaches()
 {
     var coaches = new Coach
     {
         TeamId = _teamId,
         PhoneNumber = "052122221",
         Mail = "gfjhfkjghfkgh",
         Date = _date,
         Id = _coachId,
         Name = "Haim Kessel"
     };
     return coaches;
 }
Пример #48
0
        private int Create()
        {
            var rep = new CoachRepository(new CSBCDbContext());
            var coach = new Coach();
            try
            {

                coach.ShirtSize = cmbSizes.Text;
                coach.SeasonID = Master.SeasonId;
                coach.CompanyID = Master.CompanyId;
                coach.CreatedDate = DateTime.Today;
                coach.PeopleID = Convert.ToInt32(cmbCoaches.SelectedValue);
                if (txtCoachPhone.Text != "")
                {
                    coach.CoachPhone = txtCoachPhone.Text;
                }
                else
                {
                    coach.CoachPhone = "";
                }
                coach.CreatedUser = Session["UserName"].ToString();
                rep.Insert(coach);
                CoachId = (int)coach.CoachID;
                Session["coachId"] = CoachId;
            }
            catch (Exception ex)
            {
                Session["ErrorMSG"] = ex.Message;
            }
            return CoachId;
        }
Пример #49
0
        private bool CheckCoach(Coach actualcoach, Coach expectedCoach)
        {
            Assert.AreEqual(actualcoach.Name, expectedCoach.Name);
            Assert.AreEqual(actualcoach.PhoneNumber, expectedCoach.PhoneNumber);
            Assert.AreEqual(actualcoach.Mail, expectedCoach.Mail);

            return true;
        }
Пример #50
0
    /**
     *  This function gets a coach from its identifier
     *
     *  int coach_id: coach identifier
     *
     *  return: Coach
     *
     **/
    public Coach getCoach(int coach_id)
    {
        IDbConnection dbConnection;
        IDbCommand dbCommand;
        IDataReader reader;

        int user_id = GlobalVariables.user_id;
        connectionString = "URI=file:"+Application.dataPath + "/"+GlobalVariables.user_database;
        dbConnection = new SqliteConnection (connectionString);
        dbConnection.Open ();

        Coach coach = new Coach();
        // Select
        string sql = "SELECT c.* FROM coach AS c ";
        sql += "WHERE c.id ="+coach_id;

        //Debug.Log (sql);
        dbCommand = dbConnection.CreateCommand ();
        dbCommand.CommandText = sql;

        reader = dbCommand.ExecuteReader ();
        while(reader.Read()) {
            int _id = Int32.Parse(reader.GetString(0));
            string _name = reader.GetString (1);
            string _surname = reader.GetString (2);
            string _birthdate = reader.GetString (3);
            int _active = Int32.Parse(reader.GetString(4));
            //Load the coach
            coach = new Coach(_id,_name,_surname,_birthdate,_active);
            List<Club> clubs = getClubs(_id);
            coach.clubs = clubs;
            List<Discipline> disciplines = getCoachDisciplines(_id);
            coach.disciplines = disciplines;
            List<Activity> activities = getCoachActivities(_id);
            coach.activities = activities;
            List<Feedback> feedbacks = getCoachFeedbacks(_id);
            coach.feedbacks = feedbacks;

            //Debug.Log ("coach_id:"+coach.id+", name:"+coach.name+", surname:"+coach.surname);
        }

        if (dbCommand != null) {
            dbCommand.Dispose ();
        }
        dbCommand = null;
        if (reader != null) {
            reader.Dispose ();
        }
        reader = null;
        if (dbConnection != null) {
            dbConnection.Close ();
        }
        dbConnection = null;

        return coach;
    }
Пример #51
0
    /**
     *  This function creates a new coach or updates an existing one
     *
     *  Coach coach: coach to create or to update
     *
     *  return: void
     *
     **/
    public void saveCoach(Coach coach)
    {
        IDbConnection dbConnection;
        IDbCommand dbCommand;
        IDataReader reader;

        int user_id = GlobalVariables.user_id;

        connectionString = "URI=file:"+Application.dataPath + "/"+GlobalVariables.user_database;

        dbConnection = new SqliteConnection (connectionString);
        dbConnection.Open ();
        int id = coach.id;
        string sql="";

        if (id == 0)
        {
            // Insert new User
            //dbaccess.InsertInto ("user",values );
        }
        else
        {
            // Update coach
            sql= "UPDATE coach SET name='"+coach.name+"',surname='"+coach.surname+"',birthdate='"+coach.birthdate+"',active="+coach.active+
                " WHERE id="+id.ToString();
            //Debug.Log (sql);
        }

        dbCommand = dbConnection.CreateCommand ();
        dbCommand.CommandText = sql;

        reader = dbCommand.ExecuteReader ();

        if (dbCommand != null) {
            dbCommand.Dispose ();
        }
        dbCommand = null;
        if (reader != null) {
            reader.Dispose ();
        }
        reader = null;
        if (dbConnection != null) {
            dbConnection.Close ();
        }
        dbConnection = null;
    }
    public void Refresh_panel()
    {
        translations = GlobalVariables.translations;
        _title.GetComponent<Text> ().text = translations.getString ("preferences");
        _subtitle.GetComponent<Text> ().text = translations.getString ("change_password");

        _tab_personaldata.GetComponent<Button>().GetComponentsInChildren<Text>()[0].text= translations.getString ("personal_data") ;
        _tab_changepassword.GetComponent<Button>().GetComponentsInChildren<Text>()[0].text= translations.getString ("change_password") ;

        _label_name.GetComponent<Text> ().text = translations.getString ("name");
        _label_surname.GetComponent<Text> ().text = translations.getString ("surname");
        _label_birthdate.GetComponent<Text> ().text = translations.getString ("birthdate");

        _button_save.GetComponent<Button>().GetComponentsInChildren<Text>()[0].text = translations.getString ("save") ;

        user = GlobalVariables.user;
        string name = "";
        string surname="";
        string birthdate="";

        //Load the data depending if coach or player
        switch (user.usertype_id) {
        case (int)User_type.COACH:
            coach = _database.getCoach (GlobalVariables.user.id);
            name = coach.name;
            surname = coach.surname;
            birthdate = coach.birthdate;
            break;
        case  (int)User_type.PLAYER:
            player = _database.getPlayer(GlobalVariables.user.id);
            name = player.name;
            surname = player.surname;
            birthdate = player.birthdate;
            break;
        }

        _input_name.GetComponent<InputField> ().text = name;
        _input_surname.GetComponent<InputField> ().text = surname;
        _input_birthdate.GetComponent<InputField> ().text = birthdate;

        //Save the data in case is coach or player
        _button_save.GetComponent<Button>().onClick.AddListener(() => {

            name = _input_name.GetComponent<InputField> ().text;
            surname = _input_surname.GetComponent<InputField> ().text;
            birthdate = _input_birthdate.GetComponent<InputField> ().text;

            //If the data are not empty it saves
            if (name!="" && surname!="" && birthdate!="")
            {
                switch (user.usertype_id) {
                case (int)User_type.COACH:
                    coach = _database.getCoach (GlobalVariables.user.id);
                    coach.name = name;
                    coach.surname = surname;
                    coach.birthdate = birthdate;
                    _database.saveCoach(coach);
                    break;
                case  (int)User_type.PLAYER:
                    player = _database.getPlayer(GlobalVariables.user.id);
                    player.name = name;
                    player.surname = surname;
                    player.birthdate = birthdate;
                    _database.savePlayer(player);
                    break;
                }
                Debug.Log ("Preferences saved");
                _coach_leftpanel.Refresh_panel();
            }
            else
            {
                Debug.Log ("Error saving preferences");
            }

        });
    }
Пример #53
0
 protected abstract void WriteCoach(Coach coach);
Пример #54
0
 public DataToServer(User user, Coach coach, Player player)
 {
     this.user = user;
     this.coach = coach;
     this.player = player;
 }