Esempio n. 1
0
        public void AddAthlete_ThrowsException()
        {
            Gym     gym     = new Gym("Gym", 0);
            Athlete athlete = new Athlete("Nacepena Batka");

            Assert.Throws <InvalidOperationException>(() => gym.AddAthlete(athlete));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdGym,Name,City,Address,WorkingHours,Contact")] Gym gym)
        {
            if (id != gym.IdGym)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gym);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GymExists(gym.IdGym))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gym));
        }
Esempio n. 3
0
        public void TestGymClass()
        {
            // arrange
            int age1 = 20;
            int age2 = 25;

            Gym gym = new Gym(age1);

            gym = new Gym(age2);

            var expected  = 14;   //Минимальный возраст ответ
            var expected1 = 25;   //Максимальный возраст ответ
            var expected2 = 19.7; //Средний возраст ответ

            // act
            gym.Main();
            var actual  = gym.MinAgeClient; //Минимальный возраст подчет
            var actual1 = gym.MaxAgeClient; //Максимальный возраст подчет
            var actual2 = gym.AvgAgeClient; //Средний возраст подчет

            // assert
            Assert.AreEqual(expected, actual);   // Сравнение
            Assert.AreEqual(expected1, actual1); // Сравнение
            Assert.AreEqual(expected2, actual2); // Сравнение
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,StartTime,Duration,Description")] Gym gym)
        {
            if (id != gym.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gym);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GymExists(gym.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gym));
        }
Esempio n. 5
0
        public void GetGymData(out int gymId, out DateTime closingHour, out int discountLocal,
                               out int discountRetired, out double freeUserPrice, out String name, out DateTime openingHour,
                               out int zipCode, out ICollection <int> activityIds, out ICollection <int> roomIds)
        {
            if (dal.GetAll <Gym>().Count() == 0)
            {
                throw new ServiceException("No hay gimasios disponibles");
            }
            Gym g = dal.GetAll <Gym>().First();

            gymId           = g.Id;
            closingHour     = g.ClosingHour;
            discountLocal   = g.DiscountLocal;
            discountRetired = g.DiscountRetired;
            freeUserPrice   = g.FreeUserPrice;
            name            = g.Name;
            openingHour     = g.OpeningHour;
            zipCode         = g.ZipCode;
            activityIds     = new List <int>();
            foreach (Activity a in g.Activities)
            {
                activityIds.Add(a.Id);
            }
            roomIds = new List <int>();
            foreach (Room r in g.Rooms)
            {
                roomIds.Add(r.Id);
            }
        }
Esempio n. 6
0
        public bool CreateGym(GymCreate model)
        {
            var entity = new Gym()
            {
                Name             = model.Name,
                MonthlyCost      = model.MonthlyCost,
                Hours            = model.Hours,
                Description      = model.Description,
                Address          = model.Address,
                Phone            = model.Phone,
                Website          = model.Website,
                Size             = model.Size,
                Equipment        = model.Equipment,
                LockerRoom       = model.LockerRoom,
                Classes          = model.Classes,
                PersonalTraining = model.PersonalTraining,
                AdditionalInfo   = model.AdditionalInfo,
                CityId           = model.CityId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Gyms.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public Gym GetGym(int userId)
        {
            Gym gym = new Gym();

            using (MySqlConnection connection = new MySqlConnection(connectionString)) {
                connection.Open();

                string query = "SELECT g.* FROM Gym g JOIN gym_user gu ON g.Id = gu.GymId WHERE gu.UserId = @userId";

                MySqlCommand mysqlcommand = new MySqlCommand(query, connection);

                mysqlcommand.Parameters.AddWithValue("@userId", userId);

                MySqlDataReader mySqlDataReader = mysqlcommand.ExecuteReader();

                if (mySqlDataReader.HasRows)
                {
                    while (mySqlDataReader.Read())
                    {
                        gym.Id   = mySqlDataReader.GetInt32(mySqlDataReader.GetOrdinal("Id"));
                        gym.Name = mySqlDataReader.GetString(mySqlDataReader.GetOrdinal("Name"));
                    }
                }

                mySqlDataReader.Close();
            }

            return(gym);
        }
        private void listGyms_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Gym secilen = new Gym();

            secilen          = (Gym)listGyms.SelectedItem;
            grd1.DataContext = secilen;
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Bouldering bouldering = new Bouldering(9.3);
            Lead       lead       = new Lead();
            Gym        gym        = new Gym();

            Climbing[] climbings =
            {
                new Climbing(),
                new Roped(),
                new Bouldering(),
                new Lead(),
                new Climbing(9, 3, 1)
            };

            climbings[0].PrintGradeStyle();
            climbings[1].PrintGradeStyle();
            climbings[2].PrintGradeStyle();
            climbings[0].Indoor();
            climbings[1].Indoor();
            climbings[3].Indoor();
            Console.WriteLine(bouldering.Height);
            bouldering.Height = 20;
            Console.WriteLine(bouldering.Height);
            Console.WriteLine(climbings[4].ClimbsInSession());

            Console.ReadLine();
        }
Esempio n. 10
0
        internal double PriceGetTest([PexAssumeUnderTest] Gym target)
        {
            double result = target.Price;

            return(result);
            // TODO: add assertions to method GymTest.PriceGetTest(Gym)
        }
Esempio n. 11
0
        internal int TotalNumGetTest([PexAssumeUnderTest] Gym target)
        {
            int result = target.TotalNum;

            return(result);
            // TODO: add assertions to method GymTest.TotalNumGetTest(Gym)
        }
Esempio n. 12
0
        internal string LocationGetTest([PexAssumeUnderTest] Gym target)
        {
            string result = target.Location;

            return(result);
            // TODO: add assertions to method GymTest.LocationGetTest(Gym)
        }
Esempio n. 13
0
        internal string ToStringTest([PexAssumeUnderTest] Gym target)
        {
            string result = target.ToString();

            return(result);
            // TODO: add assertions to method GymTest.ToStringTest(Gym)
        }
Esempio n. 14
0
        internal bool BookSessionTest([PexAssumeUnderTest] Gym target)
        {
            bool result = target.BookSession();

            return(result);
            // TODO: add assertions to method GymTest.BookSessionTest(Gym)
        }
Esempio n. 15
0
        public bool UpdateGym(int id, Gym gymDetails)
        {
            bool isSuccess = false;

            try
            {
                using (var ctx = new FitnessproEntities())
                {
                    Gym gymdetails = ctx.Gyms.Where(x => x.GymId == id).SingleOrDefault();
                    gymdetails.FirstName       = gymDetails.FirstName;
                    gymdetails.LastName        = gymDetails.LastName;
                    gymdetails.GymName         = gymDetails.GymName;
                    gymdetails.MobileNumber    = gymDetails.MobileNumber;
                    gymdetails.TelephoneNumber = gymDetails.TelephoneNumber;
                    gymdetails.EnrolledDate    = gymDetails.EnrolledDate;
                    gymdetails.Email           = gymDetails.Email;
                    gymdetails.EstablishedYear = gymDetails.EstablishedYear;
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                isSuccess = false;
                throw;
            }
            return(isSuccess);
        }
Esempio n. 16
0
        public ActionResult New()
        {
            Gym gym = new Gym();

            gym.LocationsList = GetAllCities();
            return(View(gym));
        }
Esempio n. 17
0
        public static Gym GetItem(int gymId)
        {
            Gym tempItem = null;
            {
                using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
                {
                    using (SqlCommand myCommand = new SqlCommand("usp_GetGym", myConnection))
                    {
                        myCommand.CommandType = CommandType.StoredProcedure;

                        myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetItem);
                        myCommand.Parameters.AddWithValue("@GymId", gymId);

                        myConnection.Open();

                        using (SqlDataReader myReader = myCommand.ExecuteReader())
                        {
                            if (myReader.Read())
                            {
                                tempItem = FillDataRecord(myReader);
                            }
                            myReader.Close();
                        }
                    }
                }
                return(tempItem);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Create Gym, receives a model (new gym), and pushes into Gym, via db context
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int CreateGym(GymViewModel model)
        {
            int gymId = 0;

            Gym entity = new Gym
            {
                GymName     = model.GymName,
                GymPrice    = model.GymPrice,
                GymAddress1 = model.GymAddress1,
                GymAddress2 = model.GymAddress2,
                GymUrl      = model.GymUrl
            };

            //inside of gym table, add in information being passed down
            _dbContext.Gyms.Add(entity);

            try
            {
                //save changes, updates table and creates a gym id
                _dbContext.SaveChanges();

                //gym id is available via savechanges
                gymId = entity.GymId;
            }
            catch (Exception)
            {
                throw;
            }

            return(gymId);
        }
Esempio n. 19
0
        public IActionResult EditGym(int id)
        {
            // Retrieve the gym from the database to be edited by the user.
            Gym gym = gymRepository.GetGym(id);

            if (gym != null)
            {
                GymViewModel model = new GymViewModel
                {
                    Id             = gym.Id,
                    GymName        = gym.GymName,
                    Email          = gym.Email,
                    AddressLineOne = gym.AddressLineOne,
                    AddressLineTwo = gym.AddressLineTwo,
                    Town           = gym.Town,
                    Postcode       = gym.Postcode,
                    Telephone      = gym.Telephone
                };

                return(View(model));
            }
            else
            {
                return(RedirectToAction(nameof(ListGyms)));
            }
        }
Esempio n. 20
0
        private static void Main(string[] args)
        {
            //Pokemon pokemon1 = new Bulbasaur();
            //pokemon1.Hp = 200;

            //Pokemon pokemon2 = new Ivysaur();
            //pokemon2.Hp = 185;

            //if (args.Length >= 2)
            // {
            //     Pokemon pokemon1 = PokemonFactory.Creat(args[0]);
            //     Pokemon pokemon2 = PokemonFactory.Creat(args[1]);
            //
            //     Console.WriteLine(pokemon1.PowerUpCandy[pokemon1.Name]);
            //     pokemon1.Attack(pokemon2);
            // }
            //  else
            // {
            //     Console.WriteLine("參數輸入錯誤");
            // }

            if (args.Length >= 2)
            {
                Gym gym = new Gym(args);
                gym.Fight();
            }
            else
            {
                Console.WriteLine("參數輸入錯誤");
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Update gym, IF we find the ID of the gym being changed
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateGym(GymViewModel model)
        {
            int rowsAffected = 0;

            Gym entity = _dbContext.Gyms.Find(model.GymId);

            if (entity != null)
            {
                entity.GymName     = model.GymName;
                entity.GymPrice    = model.GymPrice;
                entity.GymAddress1 = model.GymAddress1;
                entity.GymAddress2 = model.GymAddress2;
                entity.GymUrl      = model.GymUrl;

                try
                {
                    rowsAffected = _dbContext.SaveChanges();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(rowsAffected);
        }
Esempio n. 22
0
 public GymEditCommand(Gym gym)
 {
     GymId = gym.Id;
     GymName = gym.Name;
     Location = gym.Location;
     IsSmallGym = gym.IsSmallGym;
 }
Esempio n. 23
0
        public async Task <List <Gym> > GetAllGym()
        {
            FirebaseResponse response = await client.GetTaskAsync("Gyms");

            Dictionary <string, GymNeeded> dict = new Dictionary <string, GymNeeded>();

            dict = JsonConvert.DeserializeObject <Dictionary <string, GymNeeded> >(response.Body);

            List <Gym> gyms = new List <Gym>();

            if (dict != null && dict.Count != 0)
            {
                foreach (var c in dict)
                {
                    Gym cc = new Gym
                    {
                        id        = c.Key,
                        isDeleted = c.Value.isDeleted,
                        name      = c.Value.name
                    };
                    gyms.Add(cc);
                }
            }

            return(gyms);
        }
        public Gym GetGymById(int id)
        {
            Gym gym = new Gym();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    string     sqlQuery = @"SELECT * FROM Gym WHERE GymId = @id";
                    SqlCommand cmd      = new SqlCommand(sqlQuery, conn);
                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        gym = DataToRow(rdr);
                    }
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Sorry that Gym does not exist.");
            }
            return(gym);
        }
Esempio n. 25
0
        internal Gym ConstructorTest(string location)
        {
            Gym target = new Gym(location);

            return(target);
            // TODO: add assertions to method GymTest.ConstructorTest(String)
        }
 public GymDetailViewModel(ContentPage page, Gym selectedGym) : base(page)
 {
     if (selectedGym != null)
     {
         currentGym = selectedGym;
     }
 }
        public List <Gym> ListAllGyms()
        {
            List <Gym> allGyms = new List <Gym>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    string        sqlQuery = "Select * from Gym";
                    SqlCommand    cmd      = new SqlCommand(sqlQuery, conn);
                    SqlDataReader rdr      = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        Gym gym = DataToRow(rdr);
                        allGyms.Add(gym);
                    }
                }
            }
            catch (SqlException ex)
            {
                //TODO 1: Implement logging here instead of a cw
                Console.WriteLine($"There was an error connecting to the Database {ex.Message}");
            }
            return(allGyms);
        }
Esempio n. 28
0
 public static void Load(HomeSave toLoad)
 {
     MainHouse.Load(toLoad.HouseLevel);
     Dorm.Load(toLoad.DormLevel);
     Gym.Load(toLoad.GymLevel);
     Kitchen.Load(toLoad.KitchenLevel);
 }
Esempio n. 29
0
        public ActionResult Details(int?id)
        {
            var userId = User.Identity.GetUserId();

            if (userId == null)
            {
                ViewBag.UserId = "0";
            }
            else
            {
                ViewBag.UserId = userId.ToString();
            }

            if (id.HasValue)
            {
                Gym gyms = db.Gyms.Find(id);
                IEnumerable <Review> reviews = db.Reviews.OrderByDescending(x => x.ReviewId).Where(x => x.GymId == id).ToList();
                ViewBag.Reviews = reviews;
                if (gyms != null)
                {
                    string imagesString = gyms.ImagesString;
                    gyms.Images = imagesString.Split(',').ToList();
                    ViewBag.gym = gyms;
                    return(View());
                }
                return(HttpNotFound("Couldn't find the recipe with id" + id.ToString()));
            }
            return(HttpNotFound("Missing recipe id parameter"));
        }
Esempio n. 30
0
        public ActionResult Update(int id, Gym gymRequestor)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Gym gym = db.Gyms.Find(id);
                    if (TryUpdateModel(gym))
                    {
                        gym.Name        = gymRequestor.Name;
                        gym.Adress      = gymRequestor.Adress;
                        gym.Description = gymRequestor.Description;
                        gym.Email       = gymRequestor.Email;
                        gym.WebSite     = gymRequestor.WebSite;
                        gym.PhoneNumber = gymRequestor.PhoneNumber;

                        db.SaveChanges();
                    }
                    return(RedirectToAction("Index"));
                }
                return(View(gymRequestor));
            }
            catch (Exception)
            {
                return(View(gymRequestor));
            }
        }
Esempio n. 31
0
        public async Task <IActionResult> AddGym(Gym gym)
        {
            if (ModelState.IsValid)
            {
                Gym gymCh = await _context.Gyms.FirstOrDefaultAsync(u => u.Name == gym.Name);

                if (gymCh == null)
                {
                    try
                    {
                        _context.Gyms.Add(gym);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        throw;
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Некорректные логин и(или) пароль");
                    return(View());
                }
            }
            return(RedirectToAction(nameof(EditDB)));
        }
Esempio n. 32
0
 public void Create(Gym newGym, string groupSysName)
 {
     var locals = Languages;
     newGym.Group = _entitiesSource.Groups.First(g => g.SysName == groupSysName);
     _entitiesSource.Gyms.AddObject(newGym);
     foreach (var local in locals)
     {
         newGym.GymLocals.Add(new GymLocal { Gym = newGym, LocalId = local.Id, Name = newGym.SysName, Body = String.Empty });
     }
     _entitiesSource.SaveChanges();
 }
Esempio n. 33
0
        public JsonDotNetResult Create(GymCreateCommand command)
        {
            return Execute(
                action: () =>
                            {
                                var gym = new Gym();
                                gym.Update(command);

                                RavenSession.Store(gym);
                                RavenSession.SaveChanges();

                                return new JsonDotNetResult(gym);
                            });
        }
Esempio n. 34
0
 public void Save(Gym gym)
 {
     _entitiesSource.Gyms.Attach(gym);
     _entitiesSource.ObjectStateManager.ChangeObjectState(gym, EntityState.Modified);
     _entitiesSource.SaveChanges();
 }