Exemple #1
0
        private void EditBadge()
        {
            Console.Clear();
            Badges addBadge = new Badges();

            // Display all ID's
            SeeAllBadges();
            // Ask for ID to be updated
            Console.WriteLine("Enter the Badge ID to be updated:");

            // Get ID


            // New Badge ID

            Console.WriteLine("Please enter a new badge ID:");
            string oldID = Console.ReadLine();

            addBadge.BadgeID = int.Parse(oldID);

            // Door Name
            Console.WriteLine("Please enter the accessible door numbers:");
            addBadge.DoorName = Console.ReadLine();

            // Name
            Console.WriteLine("Please enter the employees name:");
            addBadge.Name = Console.ReadLine();

            _badgesRepo.UpdateBadge(oldID, addBadge);
        }
Exemple #2
0
        public ActionResult <IEnumerable <Badges> > All(Guid userID)
        {
            NpgsqlConnection _connection = new NpgsqlConnection(connString);

            _connection.Open();
            IHabitRepository repo1   = new HabitRepository(_connection, null);
            List <Guid>      badgeID = new List <Guid>();
            List <Badge>     badge   = new List <Badge>();
            List <Badges>    badges  = new List <Badges>();

            foreach (Guid x in repo1.GetAllBadge(userID))
            {
                badgeID.Add(x);
            }

            foreach (Guid y in badgeID)
            {
                badge.Add(repo1.FindBadge(userID, y));
            }

            foreach (Badge z in badge)
            {
                Badges bg = new Badges()
                {
                    ID          = z.ID,
                    name        = z.name,
                    description = z.description,
                    user_id     = z.users,
                    created_at  = z.created_at
                };
                badges.Add(bg);
            }
            return(badges);
        }
Exemple #3
0
        public void BadgesArranged()
        {
            _repoBadge = new BadgesRepo();
            _badges    = new Badges(1, "front, back");

            _repoBadge.CreateNewBadge(_badges.BadgeID, _badges);
        }
        public void UpdateBadge()
        {
            Badges badge = new Badges();

            badge.DoorAccess = new List <string>();

            Console.Clear();
            Console.WriteLine("Please enter a badge number that you would like to edit: ");
            badge.BadgeID = int.Parse(Console.ReadLine());

            Console.Clear();
            Console.WriteLine($"What do you want to change for {badge.BadgeID}\n" +

                              $"1. Remove a door\n" +
                              $"2. Add a door\n" +
                              $"3. Return to main menu");

            string answer = Console.ReadLine();

            switch (answer)
            {
            case "1":
                RemoveDoor(badge.BadgeID);
                break;

            case "2":
                AddDoorToUpdate(badge.BadgeID);
                break;

            case "3":
                RunMenu();
                break;
            }
        }
Exemple #5
0
        public override string ToString()
        {
            string format = "{{" +
                            "\"_id\": {0}, " +
                            "\"username\": {1}," +
                            "\"displayname\": {2}," +
                            "\"avatar\": {3}," +
                            "\"color\": {4}," +
                            "\"roles\": {5}," +
                            "\"badges\": {6}" +
                            "}}";

            try {
                return(string.Format(
                           format,
                           JsonConvert.ToString(UserID),
                           JsonConvert.ToString(Username),
                           JsonConvert.ToString(DisplayName),
                           JsonConvert.ToString(Avatar),
                           JsonConvert.ToString(Color),
                           JSONUtil.ToString(Roles.ToArray()),
                           JSONUtil.ToString(Badges.ToArray())
                           ));
            } catch (Exception e) {
                Console.WriteLine(e);
                return("");
            }
        }
        public void AddBadge()
        {
            Dictionary <int, List <string> > badges = _repo.ShowAllBadges();
            Badges badge = new Badges();

            Console.WriteLine("Enter Badge ID");
            badge.BadgeID = int.Parse(Console.ReadLine());

            foreach (KeyValuePair <int, List <string> > keyValuePair in badges)
            {
                if (badges.ContainsKey(badge.BadgeID))
                {
                    Console.WriteLine("This key already exists.");
                    Console.WriteLine("Please try again...");
                    Console.ReadKey();
                    AddBadge();
                }
            }

            Console.WriteLine("Enter doors, seperate with comma");
            string doors = Console.ReadLine();

            badge.BadgeDoors = doors.Split(',').ToList();
            _repo.AddBadge(badge);
            Console.WriteLine($"Badge {badge.BadgeID} was added.");
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
        Task<StacManResponse<Badge>> IBadgeMethods.GetByIds(string site, IEnumerable<int> ids, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, Badges.AllSort? sort = null, Badges.Rank? minrank = null, Badges.Rank? maxrank = null, string minname = null, string maxname = null, Badges.BadgeType? mintype = null, Badges.BadgeType? maxtype = null, Order? order = null)
        {
            var filterObj = ValidateAndGetFilter(filter);

            ValidateString(site, "site");
            ValidateEnumerable(ids, "ids");
            ValidatePaging(page, pagesize);
            ValidateSortMinMax(sort, minrank: minrank, maxrank: maxrank, minname: minname, maxname: maxname, mintype: mintype, maxtype: maxtype);

            var ub = new ApiUrlBuilder(String.Format("/badges/{0}", String.Join(";", ids)), useHttps: false);

            ub.AddParameter("site", site);
            ub.AddParameter("filter", filter);
            ub.AddParameter("page", page);
            ub.AddParameter("pagesize", pagesize);
            ub.AddParameter("fromdate", fromdate);
            ub.AddParameter("todate", todate);
            ub.AddParameter("sort", sort);
            ub.AddParameter("min", minrank);
            ub.AddParameter("max", maxrank);
            ub.AddParameter("min", minname);
            ub.AddParameter("max", maxname);
            ub.AddParameter("min", mintype);
            ub.AddParameter("max", maxtype);
            ub.AddParameter("order", order);

            return CreateApiTask<Badge>(ub, filterObj, "/badges/{ids}");
        }
Exemple #8
0
        private MenuScreen BuildBadges(Badges badges, FishingGameContext context, ContentManager content)
        {
            BadgesScreen badgesScreen = new BadgesScreen(badges, context);

            badgesScreen.LoadContent(content);
            return(badgesScreen);
        }
        public void CreateNewBadge()
        {
            Console.Clear();
            List <string> doors = new List <string>();

            Console.WriteLine("What is the number on the badge to Create: (ie.12345)\n");
            int badgeId = int.Parse(Console.ReadLine());

            Console.WriteLine("List a Door this Badge needs access to:");
            bool doorInput = true;

            while (doorInput)
            {
                string addedDoor = Console.ReadLine();
                doors.Add(addedDoor);
                Console.WriteLine("Any other Doors? (y/n)");
                string secondDoor = Console.ReadLine().ToLower();
                if (secondDoor == "y")
                {
                    Console.WriteLine("What other door would you like to assign:");
                    string doorResponse = Console.ReadLine();
                    doors.Add(doorResponse);
                }
                else
                {
                    doorInput = false;
                }
            }
            Badges newBadge = new Badges(badgeId, doors);

            _badgesRepository.Add(newBadge.BadgeId, newBadge.DoorName);
            Console.WriteLine("This door(s) has been added. Thank you");
        }
Exemple #10
0
        public void AddBadge()
        {
            Console.Clear();
            Badges newBadge = new Badges();

            Console.WriteLine("What is the number on the badge?");
            newBadge.BadgeID = Convert.ToInt32(Console.ReadLine());

            List <string> doors = new List <string>();

            bool isYes = true;

            while (isYes)
            {
                Console.WriteLine("Do you want to add door access?(y/n)?");
                string answer = Console.ReadLine();
                if (answer == "y")
                {
                    Console.WriteLine("Enter a door for access:");
                    string ans = Console.ReadLine().ToUpper();
                    doors.Add(ans);
                }
                else
                {
                    isYes = false;
                }
            }
            newBadge.DoorName = doors;
            _repo.CreateNewBadge(newBadge.BadgeID, newBadge.DoorName);
            Menu();
        }
        //create a new badge

        public void CreateNewBadge()
        {
            Console.Clear();
            Badges newBadge = new Badges();

            //Badge Number
            Console.WriteLine("Enter the badge number:");
            string ItemasString = Console.ReadLine();

            newBadge.BadgeID = int.Parse(ItemasString);

            Console.WriteLine("List a door that it needs access to:");
            var ItemAsString = Console.ReadLine();

            bool CanRun = true;

            do
            {
                Console.WriteLine("Do you want to add access to another door? (y/n)");
                string Userinput = Console.ReadLine();
                switch (Userinput)
                {
                case "n":
                    CanRun = false;
                    break;
                }
            } while (CanRun == true);


            _badgeRepository.AddBadge(newBadge);
            Console.WriteLine("press any key to continue");
            Console.ReadKey();
        }
        private void AddABadge()
        {
            Console.WriteLine();
            Dictionary <int, Badges> listOfBadges = _badgeRepo.GetDictionaryAllBadges();
            Badges newBadge       = new Badges();
            bool   hasFilledRooms = false;

            while (hasFilledRooms == false)
            {
                Console.WriteLine($"Badge ID: {listOfBadges.Count + 1}");
                Console.WriteLine();
                Console.WriteLine("Do you want to add door access to this badge? Enter: (Y/N) ");
                string userInputHasFilledRooms = Console.ReadLine().ToLower();
                if (userInputHasFilledRooms == "y")
                {
                    Console.WriteLine("List the door this badge needs access to:");
                    string accessToDoors = Console.ReadLine();
                    newBadge.DoorNames.Add(accessToDoors);
                }
                else if (userInputHasFilledRooms == "n")
                {
                    hasFilledRooms = true;
                    _badgeRepo.AddABadge(newBadge);
                }
                else
                {
                    hasFilledRooms = true;
                    Console.WriteLine("Press any key to return to main menu");
                    Console.ReadKey();
                    ProgramMenu();
                }
            }
        }
        private void AddABadge()
        {
            Console.Clear();
            Badges newBadge = new Badges();

            Console.WriteLine("Enter the ID Number for this Badge:");
            string badgeIDAsString = Console.ReadLine();

            newBadge.BadgeID = int.Parse(badgeIDAsString);

            Console.WriteLine("Enter the doors you would like this Badge to have access to:");
            newBadge.AccessibleDoors = Console.ReadLine();

            Console.WriteLine("Any other doors? (y/n)");
            string additionalDoor = Console.ReadLine().ToLower();

            _badgesRepo.AddABadge(newBadge);

            while (additionalDoor == "y")
            {
                Console.WriteLine("Enter the doors you would like this Badge to have access to:");
                newBadge.AccessibleDoors = Console.ReadLine();
                Console.WriteLine("Any other doors? (y/n)");
                additionalDoor = Console.ReadLine();
            }
            if (additionalDoor == "n")
            {
                Console.WriteLine("All doors added");
                Console.Clear();
                Menu();
            }
        }
Exemple #14
0
        private void RemoveDoor()
        {
            Console.Clear();
            DisplayAllBadges();
            Console.WriteLine("REMOVE DOOR \n" +
                              "\n" +
                              "Please type the badge ID# that you would like to update. \n");
            int userInput = int.Parse(Console.ReadLine());

            Console.Clear();
            Badges badge = _badgesRepo.GetBadgeByID(userInput);

            ShowBadge(badge);
            Console.WriteLine("Which door would you like to remove?");
            string doorToRemove = Console.ReadLine();

            if (badge.DoorNames.Contains(doorToRemove))
            {
                _badgesRepo.DeleteExistingRoom(userInput, doorToRemove);
                Console.WriteLine("Door removed.");
            }
            else
            {
                Console.WriteLine("You entered an invalid response. No change was recorded for this badge.");
            }
            Console.WriteLine("Press any key to return to the main menu.");
            Console.ReadKey();
        }
        Task<StacManResponse<Badge>> IBadgeMethods.GetNamed(string site, string filter = null, int? page = null, int? pagesize = null, DateTime? fromdate = null, DateTime? todate = null, Badges.Sort? sort = null, Badges.Rank? minrank = null, Badges.Rank? maxrank = null, string minname = null, string maxname = null, Order? order = null, string inname = null)
        {
            var filterObj = ValidateAndGetFilter(filter);

            ValidateString(site, "site");
            ValidatePaging(page, pagesize);
            ValidateSortMinMax(sort, minrank: minrank, maxrank: maxrank, minname: minname, maxname: maxname);

            var ub = new ApiUrlBuilder("/badges/name", useHttps: false);

            ub.AddParameter("site", site);
            ub.AddParameter("filter", filter);
            ub.AddParameter("page", page);
            ub.AddParameter("pagesize", pagesize);
            ub.AddParameter("fromdate", fromdate);
            ub.AddParameter("todate", todate);
            ub.AddParameter("sort", sort);
            ub.AddParameter("min", minrank);
            ub.AddParameter("max", maxrank);
            ub.AddParameter("min", minname);
            ub.AddParameter("max", maxname);
            ub.AddParameter("order", order);
            ub.AddParameter("inname", inname);

            return CreateApiTask<Badge>(ub, filterObj, "/badges/name");
        }
Exemple #16
0
 private void ShowDoors(Badges individualDoor)
 {
     foreach (var item in individualDoor.DoorNames)
     {
         Console.WriteLine(item);
     }
 }
Exemple #17
0
        public async Task <IHttpActionResult> PutBadges(int id, Badges badges)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != badges.Id)
            {
                return(BadRequest());
            }

            db.Entry(badges).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BadgesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #18
0
        private bool Setup(Badges newBadge, bool hasFilledRooms)
        {
            if (!hasFilledRooms)
            {
                Console.WriteLine("Please add a door number:");
                string userInputDoorNumber = Console.ReadLine();
                newBadge.DoorNames.Add(userInputDoorNumber);

                Console.WriteLine("Any other doors (y/n)?");

                string userInputOtherDoors = Console.ReadLine().ToLower();
                if (userInputOtherDoors == "y")
                {
                    hasFilledRooms = Setup(newBadge, hasFilledRooms);
                    return(hasFilledRooms);
                }

                else
                {
                    hasFilledRooms = true;
                    return(hasFilledRooms);
                }
            }
            return(false);
        }
Exemple #19
0
        // Add a badge
        private void AddNewBadge()
        {
            Console.Clear();
            Badges newBadge = new Badges();

            // Badge ID
            Console.WriteLine("Enter new badge ID:");
            string badgeIDAsString = Console.ReadLine();

            newBadge.BadgeID = int.Parse(badgeIDAsString);

            // Add door name from list
            Console.WriteLine("Add a door to new badge");
            newBadge.ListOfDoorNames.Add(Console.ReadLine());

            // Add another door name from list
            Console.WriteLine("Add another door to new badge (y/n)");
            string addAnotherDoor = Console.ReadLine().ToLower();

            while (addAnotherDoor != "n")
            {
                // Add door name from list
                Console.WriteLine("Add a door to new badge");
                newBadge.ListOfDoorNames.Add(Console.ReadLine());
                Console.WriteLine("Add another door to new badge (y/n)");
                addAnotherDoor = Console.ReadLine().ToLower();
            }

            _badgesRepo.AddBadgeToDictionary(newBadge.BadgeID, newBadge.ListOfDoorNames);

            // Return user to main menu
            Console.Clear();
            Menu();
        }
        Task<StacManResponse<Badge>> IBadgeMethods.GetAll(string site, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Badges.AllSort? sort, Badges.Rank? minrank, Badges.Rank? maxrank, string minname, string maxname, Badges.BadgeType? mintype, Badges.BadgeType? maxtype, Order? order, string inname)
        {
            ValidateString(site, "site");
            ValidatePaging(page, pagesize);
            ValidateSortMinMax(sort, minrank: minrank, maxrank: maxrank, minname: minname, maxname: maxname, mintype: mintype, maxtype: maxtype);

            var ub = new ApiUrlBuilder(Version, "/badges", useHttps: false);

            ub.AddParameter("site", site);
            ub.AddParameter("filter", filter);
            ub.AddParameter("page", page);
            ub.AddParameter("pagesize", pagesize);
            ub.AddParameter("fromdate", fromdate);
            ub.AddParameter("todate", todate);
            ub.AddParameter("sort", sort);
            ub.AddParameter("min", minrank);
            ub.AddParameter("max", maxrank);
            ub.AddParameter("min", minname);
            ub.AddParameter("max", maxname);
            ub.AddParameter("min", mintype);
            ub.AddParameter("max", maxtype);
            ub.AddParameter("order", order);
            ub.AddParameter("inname", inname);

            return CreateApiTask<Badge>(ub, HttpMethod.GET, "/badges");
        }
Exemple #21
0
        public void GetAllBadges_ShouldReturnAll()
        {
            Badges     allBadges     = new Badges();
            BadgesRepo allBadgesRepo = new BadgesRepo();

            allBadgesRepo.AddBadgeToDictionary(allBadges);
        }
Exemple #22
0
        protected int populate_DDL()
        {
            int            val;
            SqlConnection  con = GetSqlCon.GetCon();
            SqlDataAdapter com = new SqlDataAdapter("GetWorkshopNamesByRegion", con);

            com.SelectCommand.CommandType = CommandType.StoredProcedure;
            com.SelectCommand.Parameters.AddWithValue("@param1", DdlRegiao.SelectedValue);
            DataSet ds1 = new DataSet();

            if (com != null)
            {
                com.Fill(ds1);
            }
            con.Open();
            DdlOficinas.DataSource     = ds1;
            DdlOficinas.DataTextField  = "WorkshopName";
            DdlOficinas.DataValueField = "WorkshopName";
            DdlOficinas.DataBind();
            con.Close();

            val = Badges.CountWorkshopsInRegion(DdlRegiao.SelectedValue);
            if (val == -1)
            {
                Response.Redirect("~/Error.aspx");
            }
            return(val);
        }
Exemple #23
0
        public void UpdateABadge()
        {
            Badges badge = new Badges();

            badge.Access = new List <string>();

            Console.Clear();
            Console.WriteLine("Enter the Badge that You Would Like to Update:");
            badge.BadgeID = int.Parse(Console.ReadLine());

            Console.Clear();
            Console.WriteLine("How Do You Want To Update the Badge?\n" +
                              "1. Add a Door\n" +
                              "2. Remove a Door\n" +
                              "0. Exit");

            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                AddDoorProgram(badge.BadgeID);
                break;

            case "2":
                //Remove a door
                RemoveDoorProgram(badge.BadgeID);
                break;

            case "3":
                Menu();
                break;
            }
        }
Exemple #24
0
        public void UpdateBadgeAccess_ReturnTrue()
        {
            Badges newBadge    = new Badges(1, "leftside, back");
            bool   updateBadge = _repoBadge.UpdateBadgeAccess(1, newBadge);

            Assert.IsTrue(updateBadge);
        }
        public async Task <IActionResult> UpdateUser(int tripId)
        {
            var userId    = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var bikerInfo = await _applicationDbContext.BikerInfos.Include(b => b.Trips).Include(b => b.Badges).FirstOrDefaultAsync(biker => biker.UserId == userId);

            var trips = await _applicationDbContext.Trips.FirstOrDefaultAsync(t => t.Id == tripId);

            var startingTotalMiles = bikerInfo.TotalMiles;

            bikerInfo.TotalMiles += (int)trips.TripMiles;
            var roundedMiles = Math.Floor(((double)bikerInfo.TotalMiles / 100)) * 100;

            if (roundedMiles > startingTotalMiles)
            {
                var newBadge = new Badges()
                {
                    Name     = $"{roundedMiles} badge",
                    Desc     = $"badge for passing {roundedMiles}",
                    MaxMiles = (int)roundedMiles
                };
                _applicationDbContext.Badges.Add(newBadge);
                bikerInfo.Badges.Add(newBadge);
                _applicationDbContext.Update(bikerInfo);
                await _applicationDbContext.SaveChangesAsync();

                //Make new View
                return(View("Index", bikerInfo));
            }
            else
            {
                _applicationDbContext.Update(bikerInfo);
                await _applicationDbContext.SaveChangesAsync();
            }
            return(View("Index", bikerInfo));
        }
        public async Task <bool> CheckBadges(BikerInfo biker)
        {
            var milesTraveled = biker.TotalMiles;
            var milesTraveledRoundedDownToNearestHundred = Math.Floor((double)milesTraveled / 100) * 100;
            var numberOfHundreds = milesTraveledRoundedDownToNearestHundred / 100;
            int hundreds         = 0;

            biker.Badges.RemoveAll(_ => _.MaxMiles > milesTraveledRoundedDownToNearestHundred); //trim out any excess from a trip deletion

            for (int i = 1; i <= numberOfHundreds; i++)
            {
                hundreds = i * 100;
                if (!biker.Badges.Exists(_ => _.MaxMiles == hundreds))
                {
                    var newBadge = new Badges()
                    {
                        Name     = $"{hundreds} badge",
                        Desc     = $"badge for passing {hundreds} hundred miles",
                        MaxMiles = hundreds
                    };
                    _applicationDbContext.Badges.Add(newBadge);
                    biker.Badges.Add(newBadge);
                    //     _applicationDbContext.Update(newBadge);
                    _applicationDbContext.Update(biker);

                    await _applicationDbContext.SaveChangesAsync();
                }
            }

            return(true);
        }
Exemple #27
0
        private void AddDoor()
        {
            Console.Clear();
            Console.WriteLine("ADD DOOR ACCESS \n" +
                              "\n" +
                              "Please type the badge ID# that you would like to update. \n");
            int userInput = int.Parse(Console.ReadLine());

            Console.Clear();
            Badges badge = _badgesRepo.GetBadgeByID(userInput);

            ShowBadge(badge);
            Console.WriteLine("What door would you like to add?");
            string doorToAdd = Console.ReadLine();

            if (!badge.DoorNames.Contains(doorToAdd))
            {
                _badgesRepo.AddNewRoom(userInput, doorToAdd);
                Console.WriteLine("Door added.");
            }
            else
            {
                Console.WriteLine("You entered an invalid response. No change was recorded for this badge.");
            }
            Console.WriteLine("Press any key to return to the main menu.");
            Console.ReadKey();
        }
Exemple #28
0
 /// <summary>
 /// Creates an Instance of the TwitchAPI Class.
 /// </summary>
 /// <param name="logger">Instance Of Logger, otherwise no logging is used,  </param>
 /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param>
 public TwitchAPI(ILogger <TwitchAPI> logger = null, IRateLimiter rateLimiter = null)
 {
     _logger         = logger;
     _http           = new HttpClient(new TwitchLibCustomHttpMessageHandler(new HttpClientHandler(), _logger));
     _rateLimiter    = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
     Auth            = new Auth(this);
     Blocks          = new Blocks(this);
     Badges          = new Badges(this);
     Bits            = new Bits(this);
     ChannelFeeds    = new ChannelFeeds(this);
     Channels        = new Channels(this);
     Chat            = new Chat(this);
     Clips           = new Clips(this);
     Collections     = new Collections(this);
     Communities     = new Communities(this);
     Follows         = new Follows(this);
     Games           = new Games(this);
     Ingests         = new Ingests(this);
     Root            = new Root(this);
     Search          = new Search(this);
     Streams         = new Streams(this);
     Subscriptions   = new Subscriptions(this);
     Teams           = new Teams(this);
     ThirdParty      = new ThirdParty(this);
     Undocumented    = new Undocumented(this);
     Users           = new Users(this);
     Videos          = new Videos(this);
     Webhooks        = new Webhooks(this);
     Debugging       = new Debugging();
     Settings        = new ApiSettings(this);
     _jsonSerializer = new TwitchLibJsonSerializer();
 }
Exemple #29
0
        private void AddBadge()
        {
            Console.Clear();
            Badges newBadge = new Badges();

            Console.WriteLine("ADD A BADGE \n" +
                              "\n");
            Console.WriteLine("What is the number on the badge:");
            newBadge.BadgeID = int.Parse(Console.ReadLine());

            bool hasFilledRooms = false;

            while (hasFilledRooms == false)
            {
                hasFilledRooms = Setup(newBadge, hasFilledRooms);
            }
            bool isSuccessful = _badgesRepo.AddBadgeToDictionary(newBadge);

            if (isSuccessful)
            {
                Console.WriteLine("Looks like you're all done." +
                                  "\n" +
                                  "Press any key to return to the Main Menu.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Press any key to return to the Main Menu.");
                Console.ReadKey();
            }
        }
Exemple #30
0
        public MenuScreen Create(Options options, Badges badges, FishingGameContext context, ContentManager content)
        {
            _menuFont  = content.Load <SpriteFont>("Fonts/Text");         // use a common font
            _menuSound = content.Load <SoundEffect>("Sounds/MenuSelect"); // use a common selected sound

            MenuScreen screen = new MenuScreen(context);

            screen.IsRoot = true;
            screen.LoadContent(content);

            MenuScreen badgesScreen  = BuildBadges(badges, context, content);
            MenuScreen optionsScreen = BuildOptions(options, context, content);
            MenuScreen confirmScreen = BuildExitConfirm(context, content);
            MenuScreen upsellScreen  = BuildExitUpsell(context, content);

            screen.AddEntry(BuildTextEntry(Resources.MenuResume, (s, a) => screen.Stack.Pop()));
            if (Guide.IsTrialMode)
            {
                MenuEntry purchase = BuildTextEntry(Resources.MenuPurchase, (s, a) => ShowPurchaseScreen(context));
                screen.AddEntry(purchase);
                context.Trial.TrialModeEnded += delegate(object s, EventArgs a) { screen.RemoveEntry(purchase); screen.LayoutEntries(); };
            }
            screen.AddEntry(BuildTextEntry(Resources.MenuBadges, (s, a) => screen.Stack.Push(badgesScreen)));
            screen.AddEntry(BuildTextEntry(Resources.MenuHelpOptions, (s, a) => screen.Stack.Push(optionsScreen)));
            screen.AddEntry(BuildTextEntry(Resources.MenuExit, (s, a) => screen.Stack.Push(Guide.IsTrialMode ? upsellScreen : confirmScreen)));
            screen.LayoutEntries();

            return(screen);
        }
Exemple #31
0
        private void SeedContentList()
        {
            List <string> seedContentOne = new List <string>();
            Badges        badgeOne       = new Badges();

            seedContentOne.Add("A7");
            badgeOne.BadgeID    = 12345;
            badgeOne.doorAccess = seedContentOne;
            _badgeRepo.NewBadge(badgeOne);

            List <string> seedContentTwo = new List <string>();
            Badges        badgeTwo       = new Badges();

            seedContentTwo.Add("A1");
            seedContentTwo.Add("A4");
            seedContentTwo.Add("B1");
            seedContentTwo.Add("B2");
            badgeTwo.BadgeID    = 22345;
            badgeTwo.doorAccess = seedContentTwo;
            _badgeRepo.NewBadge(badgeTwo);

            List <string> seedContentThree = new List <string>();
            Badges        badgeThree       = new Badges();

            seedContentThree.Add("A4");
            seedContentThree.Add("A5");
            badgeThree.BadgeID    = 32345;
            badgeThree.doorAccess = seedContentThree;
            _badgeRepo.NewBadge(badgeThree);
        }
Exemple #32
0
 /// <summary>
 /// Creates an Instance of the TwitchAPI Class.
 /// </summary>
 /// <param name="logger">Instance Of Logger, otherwise no logging is used,  </param>
 /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param>
 public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IHttpCallHandler http = null)
 {
     _logger         = loggerFactory?.CreateLogger <TwitchAPI>();
     _http           = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
     _rateLimiter    = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
     Analytics       = new Analytics(this);
     Auth            = new Auth(this);
     Badges          = new Badges(this);
     Bits            = new Bits(this);
     ChannelFeeds    = new ChannelFeeds(this);
     Channels        = new Channels(this);
     Chat            = new Chat(this);
     Clips           = new Clips(this);
     Collections     = new Collections(this);
     Communities     = new Communities(this);
     Entitlements    = new Entitlements(this);
     Games           = new Games(this);
     Ingests         = new Ingests(this);
     Root            = new Root(this);
     Search          = new Search(this);
     Streams         = new Streams(this);
     Teams           = new Teams(this);
     ThirdParty      = new ThirdParty(this);
     Undocumented    = new Undocumented(this);
     Users           = new Users(this);
     Videos          = new Videos(this);
     Webhooks        = new Webhooks(this);
     Debugging       = new Debugging();
     Settings        = new ApiSettings(this);
     _jsonSerializer = new TwitchLibJsonSerializer();
 }
        public async Task <Badges> UpdateExperienceAsync(int courseId, ExperienceForListDTO experienceForListDTO)
        {
            var category = await _repository.GetCategoryOfExamAsync(courseId);

            int categoryID = category.CategoryId;

            var experience_current = await _repository.GetUserExperienceByCategoryAsync(experienceForListDTO.UserId, categoryID);

            if (experience_current == null)
            {
                experienceForListDTO.CategoryId = categoryID;
                var exp_to_post = _mapper.Map <Experience>(experienceForListDTO);
                await _repository.AddExperienceAsync(exp_to_post);
            }
            else
            {
                var experience    = _repository.GetExperienceFromBase(experience_current.Id);
                var exp_from_base = experience.ExperiencePoints;

                experienceForListDTO.CategoryId = categoryID;

                var exp_to_add = exp_from_base + experienceForListDTO.ExperiencePoints;
                experienceForListDTO.ExperiencePoints = exp_to_add;
                experience.CategoryId = categoryID;

                var exp = _mapper.Map(experienceForListDTO, experience);
                await _repository.UpdateExperienceAsync(exp);

                // przydzielanie odznaki


                var badges_by_category = await _badgeRepository.GetBadgeByCategoryAsync(exp.CategoryId);

                foreach (var badge in badges_by_category)
                {
                    var assign = await _badgeRepository.GetAssignment(exp.UserId, badge.Id);

                    if (assign == null)
                    {
                        if (exp.ExperiencePoints >= badge.ExperiencePoints)
                        {
                            assignmentBadge = true;
                            BadgeAssignment assignment = new BadgeAssignment();
                            assignment.BadgeId = badge.Id;
                            assignment.UserId  = exp.UserId;

                            obtainedBadgeId = badge.Id;

                            await _badgeRepository.AssignBadge(assignment);
                        }
                    }
                }
                if (assignmentBadge == true)
                {
                    obtainedBadge = await _badgeRepository.GetBadgeAsync(obtainedBadgeId);
                }
            }
            return(obtainedBadge);
        }
        Task<StacManResponse<Badge>> IUserMethods.GetMyBadges(string site, string access_token, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Badges.UserSort? sort, Badges.Rank? minrank, Badges.Rank? maxrank, string minname, string maxname, Badges.BadgeType? mintype, Badges.BadgeType? maxtype, DateTime? mindate, DateTime? maxdate, Order? order)
        {
            ValidateString(site, "site");
            ValidateString(access_token, "access_token");
            ValidatePaging(page, pagesize);
            ValidateSortMinMax(sort, minrank: minrank, maxrank: maxrank, minname: minname, maxname: maxname, mintype: mintype, maxtype: maxtype, mindate: mindate, maxdate: maxdate);

            var ub = new ApiUrlBuilder(Version, "/me/badges", useHttps: true);

            ub.AddParameter("site", site);
            ub.AddParameter("access_token", access_token);
            ub.AddParameter("filter", filter);
            ub.AddParameter("page", page);
            ub.AddParameter("pagesize", pagesize);
            ub.AddParameter("fromdate", fromdate);
            ub.AddParameter("todate", todate);
            ub.AddParameter("sort", sort);
            ub.AddParameter("min", minrank);
            ub.AddParameter("max", maxrank);
            ub.AddParameter("min", minname);
            ub.AddParameter("max", maxname);
            ub.AddParameter("min", mintype);
            ub.AddParameter("max", maxtype);
            ub.AddParameter("min", mindate);
            ub.AddParameter("max", maxdate);
            ub.AddParameter("order", order);

            return CreateApiTask<Badge>(ub, HttpMethod.GET, "/_users/badges");
        }
        Task<StacManResponse<Badge>> IUserMethods.GetBadges(string site, IEnumerable<int> ids, string filter, int? page, int? pagesize, DateTime? fromdate, DateTime? todate, Badges.UserSort? sort, Badges.Rank? minrank, Badges.Rank? maxrank, string minname, string maxname, Badges.BadgeType? mintype, Badges.BadgeType? maxtype, DateTime? mindate, DateTime? maxdate, Order? order)
        {
            ValidateString(site, "site");
            ValidateEnumerable(ids, "ids");
            ValidatePaging(page, pagesize);
            ValidateSortMinMax(sort, minrank: minrank, maxrank: maxrank, minname: minname, maxname: maxname, mintype: mintype, maxtype: maxtype, mindate: mindate, maxdate: maxdate);

            var ub = new ApiUrlBuilder(Version, String.Format("/users/{0}/badges", String.Join(";", ids)), useHttps: false);

            ub.AddParameter("site", site);
            ub.AddParameter("filter", filter);
            ub.AddParameter("page", page);
            ub.AddParameter("pagesize", pagesize);
            ub.AddParameter("fromdate", fromdate);
            ub.AddParameter("todate", todate);
            ub.AddParameter("sort", sort);
            ub.AddParameter("min", minrank);
            ub.AddParameter("max", maxrank);
            ub.AddParameter("min", minname);
            ub.AddParameter("max", maxname);
            ub.AddParameter("min", mintype);
            ub.AddParameter("max", maxtype);
            ub.AddParameter("min", mindate);
            ub.AddParameter("max", maxdate);
            ub.AddParameter("order", order);

            return CreateApiTask<Badge>(ub, HttpMethod.GET, "/_users/badges");
        }