public void Remove(Guid id)
        {
            Penalty penalty = GetById(id);

            penalty.Status = DAL.Entity.Enum.Status.Deleted;
            Update(penalty);
        }
        public ActionResult Edit(PenaltyViewModel model)
        {
            if (ModelState.IsValid)
            {
                Penalty penaltyToUpdate = penaltyService.Get(model.Penalty.Id);
                TryUpdateModel(penaltyToUpdate, "Penalty");

                penaltyToUpdate.League = leagueService.Get(model.LeagueId);
                penaltyToUpdate.Team   = teamService.Get(model.TeamId);

                penaltyService.Save(penaltyToUpdate);

                UpdateTeamLeaguePenaltiesAndStats(model.LeagueId, model.TeamId);

                penaltyService.Commit();

                SuccessMessage(FormMessages.SaveSuccess);

                return(RedirectToAction("Index"));
            }

            PopulateStaticData(model);

            return(View(model));
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 26, Configuration.FieldSeparator),
                       Id,
                       SetIdIn3.HasValue ? SetIdIn3.Value.ToString(culture) : null,
                       CertificationNumber?.ToDelimitedString(),
                       CertifiedBy != null ? string.Join(Configuration.FieldRepeatSeparator, CertifiedBy.Select(x => x.ToDelimitedString())) : null,
                       CertificationRequired,
                       Penalty?.ToDelimitedString(),
                       CertificationDateTime.HasValue ? CertificationDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       CertificationModifyDateTime.HasValue ? CertificationModifyDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       Operator != null ? string.Join(Configuration.FieldRepeatSeparator, Operator.Select(x => x.ToDelimitedString())) : null,
                       CertificationBeginDate.HasValue ? CertificationBeginDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       CertificationEndDate.HasValue ? CertificationEndDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       Days?.ToDelimitedString(),
                       NonConcurCodeDescription?.ToDelimitedString(),
                       NonConcurEffectiveDateTime.HasValue ? NonConcurEffectiveDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       PhysicianReviewer != null ? string.Join(Configuration.FieldRepeatSeparator, PhysicianReviewer.Select(x => x.ToDelimitedString())) : null,
                       CertificationContact,
                       CertificationContactPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, CertificationContactPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       AppealReason?.ToDelimitedString(),
                       CertificationAgency?.ToDelimitedString(),
                       CertificationAgencyPhoneNumber != null ? string.Join(Configuration.FieldRepeatSeparator, CertificationAgencyPhoneNumber.Select(x => x.ToDelimitedString())) : null,
                       PreCertificationRequirement != null ? string.Join(Configuration.FieldRepeatSeparator, PreCertificationRequirement.Select(x => x.ToDelimitedString())) : null,
                       CaseManager,
                       SecondOpinionDate.HasValue ? SecondOpinionDate.Value.ToString(Consts.DateFormatPrecisionDay, culture) : null,
                       SecondOpinionStatus?.ToDelimitedString(),
                       SecondOpinionDocumentationReceived != null ? string.Join(Configuration.FieldRepeatSeparator, SecondOpinionDocumentationReceived.Select(x => x.ToDelimitedString())) : null,
                       SecondOpinionPhysician != null ? string.Join(Configuration.FieldRepeatSeparator, SecondOpinionPhysician.Select(x => x.ToDelimitedString())) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutPenalty(int id, Penalty penalty)
        {
            if (id != penalty.PenaltyID)
            {
                return(BadRequest());
            }

            _context.Entry(penalty).State = EntityState.Modified;

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

            return(NoContent());
        }
Exemplo n.º 5
0
        public override void Run()
        {
            Description = $"It's a narrow part of the trail and everyone has to walk in a tight group when someone farts!\n\n\"Who dun did it?\"";

            Options = new Dictionary <string, Option>();

            var farters = Party.GetRandomCompanions(3);

            string optionResultText;

            foreach (var farter in farters)
            {
                optionResultText = $"{farter.FirstName()} is the culprit!\n\nThe stench sticks to them like glue!\n\n\"Maybe check your drawers...\"";

                var optionPenalty = new Penalty();

                optionPenalty.AddEntityLoss(farter, EntityStatTypes.CurrentMorale, 10);

                var option = new Option(farter.Name, optionResultText, null, optionPenalty, EncounterType.Normal);

                Options.Add(farter.Name, option);
            }

            var optionTitle = "Burrito Ghost";

            var battleChance = 100;

            optionResultText = $"{farters.First().FirstName()} scoffs.\n\n\"Ain't no such thing as ghost wandering around, farting, and moaning 'burrito'!\"";

            var roll = Dice.Roll("1d100");

            Option optionFour;

            if (roll < battleChance)
            {
                optionResultText += $"\n\n\"BURRRIIIIIITOOOO...\" something moans back. Everyone stops and looks around. Suddenly, another fart blasts their nostrils and the culprit reveals themself!\n\nThe Burrito Ghost is real, y'all! Prepare for battle!";

                optionFour = new FightCombatOption(optionTitle, optionResultText, new List <Entity> {
                    new BurritoGhost(), new Ghost(), new Ghost()
                });
            }
            else
            {
                optionResultText += "\n\nThe mystery remains unsolved.";

                var optionFourPenalty = new Penalty();

                optionFourPenalty.EveryoneLoss(Party, EntityStatTypes.CurrentMorale, 5);

                optionFour = new Option(optionTitle, optionResultText, null, optionFourPenalty, EncounterType.Normal);
            }

            Options.Add(optionTitle, optionFour);

            SubscribeToOptionSelectedEvent();

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.FourOptionEncounter, this);
        }
        private void PenaltyBtn_Click(object sender, RoutedEventArgs e)
        {
            int clickedTime = Time.CountedSeconds();

            PenaltyOverlay penOverlay = new PenaltyOverlay();

            penOverlay.Owner = System.Windows.Window.GetWindow(this);
            bool?result = penOverlay.ShowDialog();

            if (result == true)             // Nullable<bool>
            {
                Penalty p = new Penalty(clickedTime, penOverlay.Reasoning,
                                        Color, SelectedTeam);

                Record.AlliancePenalties.Add(p);

                ListBoxItem lbi = new ListBoxItem();
                lbi.Content    = p.UIForm;
                lbi.Foreground = new SolidColorBrush(MALFUNCTIONING_RED);
                lbi.FontWeight = FontWeights.SemiBold;
                lbi.ToolTip    = "Penalty: " + p.Reasoning;
                lbi.Tag        = p;

                GoalsList.Items.Add(lbi);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Kickuje gracza z serwera.
        /// </summary>
        /// <param name="charData"></param>
        /// <param name="adminData"></param>
        /// <param name="reason"></param>
        public static void KickPlayer(Character charData, Character adminData, string reason)
        {
            if (charData == null)
            {
                return;
            }

            Penalty penaltyData = new Penalty
            {
                AdminId        = adminData?.MemberId ?? 0,
                TargetId       = charData.Id,
                TargetGlobalId = charData.MemberId,
                Type           = PenaltyType.Kick,
                Reason         = reason,
                Timestamp      = Global.GetTimestamp(),
                Expired        = 0
            };

            using (Database.Database db = new Database.Database())
            {
                db.Penalties.Add(penaltyData);
                db.SaveChanges();
            }

            ShowMessage(charData, adminData, PenaltyType.Kick, reason);

            if (NAPI.Entity.DoesEntityExist(charData.PlayerHandle))
            {
                charData.PlayerHandle.Kick(reason);
            }
        }
        private void RemoveGoalBtn_Click(object sender, RoutedEventArgs e)
        {
            ListBoxItem lbi = GoalsList.SelectedItem as ListBoxItem;

            if (lbi == null)
            {
                return;
            }

            Goal g = lbi.Tag as Goal;

            if (g == null)
            {
                Penalty p = lbi.Tag as Penalty;
                if (p != null)
                {
                    Record.AlliancePenalties.Remove(p);
                    GoalsList.Items.Remove(lbi);
                }

                return;
            }

            if (g.Type == GoalType.Coopertition)
            {
                CoopertitionBtn.IsEnabled        = true;
                CoopertitionStackedBtn.IsEnabled = true;
            }

            Record.ScoredGoals.Remove(g);
            GoalsList.Items.Remove(lbi);
        }
        public async Task <ActionResult> Create(PenaltyModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = new Penalty
                    {
                        PayRate      = model.PayRate,
                        From         = model.From,
                        To           = model.To,
                        PenaltyFee   = model.PenaltyFee,
                        LastUpdate   = DateTime.Now,
                        CreationDate = DateTime.Now,
                        IsDeleted    = false,
                    };

                    db.Penalties.Add(entity);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                AddAlert($"Oops! something went wrong. Error code: {e.HResult}", "Create(model)", this.GetType().ToString(), AlertType.error, e);
            }

            return(View(model));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Nadaje ostrzeżenie graczowi
        /// </summary>
        /// <param name="charData"></param>
        /// <param name="adminData"></param>
        /// <param name="reason"></param>
        public static void WarnPlayer(Character charData, Character adminData, string reason)
        {
            if (charData == null)
            {
                return;
            }

            reason = Command.UpperFirst(reason);

            Penalty penaltyData = new Penalty
            {
                AdminId        = adminData?.MemberId ?? 0,
                TargetId       = charData.Id,
                TargetGlobalId = charData.MemberId,
                Type           = PenaltyType.Warn,
                Reason         = reason,
                Timestamp      = Global.GetTimestamp(),
                Expired        = 0
            };

            using (Database.Database db = new Database.Database())
            {
                db.Penalties.Add(penaltyData);
                db.SaveChanges();
            }

            Player.SendFormattedChatMessage(charData.PlayerHandle, "Zostało Ci nadane ostrzeżenie",
                                            Constants.ColorDarkRed);
            Player.SendFormattedChatMessage(charData.PlayerHandle, $"Powód: {reason}", Constants.ColorDarkRed);

            ShowMessage(charData, adminData, PenaltyType.Warn, reason);
        }
Exemplo n.º 11
0
        public Penalty AddPenalty(string team = "left", int period = 1, int jam = 1, TimeSpan?timeStamp = null, int secondsOwed = 30, int number = -1)
        {
            var penalty = new Penalty(team, period, jam, timeStamp ?? TimeSpan.FromSeconds(0), secondsOwed, number);

            _state.Penalties.Add(penalty);
            return(penalty);
        }
Exemplo n.º 12
0
        public void JoinPenalty(Penalty penalty)
        {
            var user = SyncManager.Instance.User;

            // If penalty is already decided - ignore
            if (!penalty.IsUnderInvestigation)
            {
                return;
            }

            if (penalty.Users.Contains(user))
            {
                // If we are already investigating - leave
                penalty.Users.Remove(user);
            }
            else
            {
                // If we are not yet investigating - join
                penalty.JoinUser(user);

                // Sync camera
                CameraControl.ChangeCamera(penalty.Camera);
            }

            SyncManager.Instance.SendPenaltyUpdate(penalty);
            this.PenaltiesView.Refresh();
        }
        public void BookReceive(string bookName, BookViewModel bookVm, string session)
        {
            BookView bookV = (from p in bookDC.BookViews
                              where p.BookName == bookName
                              select p).FirstOrDefault();

            Book book = (from p in bookDC.Books
                         where p.BookName == bookName
                         select p).FirstOrDefault();

            bookVm.CategoryName  = bookV.CategoryName;
            bookVm.BookName      = bookV.BookName;
            bookVm.AuthorName    = bookV.AuthorName;
            bookVm.PublisherName = bookV.PublisherName;
            book.BookQuantity--;
            BookOperation BO      = new BookOperation();
            Penalty       penalty = new Penalty();

            BO.UserName      = session;
            BO.ReceivingDate = DateTime.Now;
            BO.CategoryName  = bookVm.CategoryName;
            BO.BookName      = bookVm.BookName;
            BO.AuthorName    = bookVm.AuthorName;
            BO.PublisherName = bookVm.PublisherName;
            bookDC.BookOperations.Add(BO);
            bookDC.SaveChanges();
            penalty.BookOperationId = BO.Id;
            penalty.PenaltyQuantity = 0;
            bookDC.Penalties.Add(penalty);
            bookDC.SaveChanges();
        }
Exemplo n.º 14
0
        public override void Run()
        {
            var companyName = _companyNames[Random.Range(0, _companyNames.Count)];

            Description =
                $"The party spots a large gathering and decides to check it out.\n\n'WELCOME TO THE {companyName.ToUpper()} COMPANY RETREAT!' a huge banner exclaims.\n\nYou are about to tell everyone break's over when an ENTHUSIASTIC gentleman with a ponytail challenges your party to 'unleash their inner power'. His arm is extended towards a bed of hot coals surrounded by totally thrilled employees.\n\nWho will take the challenge?";

            Options = new Dictionary <string, Option>();

            var sacrifices = Party.GetRandomCompanions(3);

            const int success = 15;

            string optionResultText;

            foreach (var sacrifice in sacrifices)
            {
                var optionReward  = new Reward();
                var optionPenalty = new Penalty();

                var coordCheck = Dice.Roll($"{sacrifice.Attributes.Coordination - 1}d6");

                var wildRoll = GlobalHelper.RollWildDie();

                coordCheck += wildRoll;

                if (coordCheck > success)
                {
                    optionResultText = $"{sacrifice.FirstName()} marches across the coals. They indeed feel a burning sensation -- not on their feet, but within. Just like the pamphlet said!";

                    optionReward.AddEntityGain(sacrifice, EntityStatTypes.CurrentMorale, 10);
                    optionReward.AddEntityGain(sacrifice, EntitySkillTypes.Endurance, 1);
                }
                else
                {
                    optionResultText = $"{sacrifice.FirstName()} tries walking on the sides of their feet to keep from burning their soles, but ends up slipping and slams onto the hot coals!";

                    optionPenalty.AddEntityLoss(sacrifice, EntityStatTypes.CurrentMorale, 5);
                    optionPenalty.AddEntityLoss(sacrifice, EntityStatTypes.CurrentHealth, 5);
                }

                var option = new Option(sacrifice.Name, optionResultText, optionReward, optionPenalty, EncounterType.Normal);

                Options.Add(sacrifice.Name, option);
            }

            var optionTitle = "Get out of there";

            optionResultText = $"The man whips his ponytail round and round in a rage!\n\n\"You'll never know true enlightenment!\"";

            var optionFour = new Option(optionTitle, optionResultText, null, null, EncounterType.Normal);

            Options.Add(optionTitle, optionFour);

            SubscribeToOptionSelectedEvent();

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.FourOptionEncounter, this);
        }
        public ActionResult BookReturn(int id, Penalty pn, int SumP, int SumK)
        {
            pn.Sum = SumP + (decimal)SumK / 100;
            if (Session["CurUsr"] == null)
            {
                Response.Redirect("~/Library/SignIn");
            }
            BookReturning BR = new BookReturning();

            if (pn.Info == null)
            {
                pn.Info = "";
            }
            BR.Penalty          = pn;
            BR.Real_Return_Date = DateTime.Today;
            BR.Librarian        = (Librarian)Session["CurUsr"];
            BookGiving bg = DM.BG.GetBookGiving(id);

            if (bg == null)
            {
                Response.Redirect("~/Library/ReadersCollection");
            }
            DM.BR.Add(bg, BR);
            return(RedirectToAction("ReaderInfo/" + bg.Reader.Id));
        }
Exemplo n.º 16
0
        public async Task <ActionResult <Penalty> > PostPenalty(Penalty penalty)
        {
            _context.Penalties.Add(penalty);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPenalty", new { id = penalty.PenaltyID }, penalty));
        }
Exemplo n.º 17
0
        public StayInSchool()
        {
            Rarity        = Rarity.Rare;
            EncounterType = EncounterType.Normal;
            Title         = "Stay In School Kids";
            Description   = @"The group spots a schoolhouse off the trail.";

            Options = new Dictionary <string, Option>();

            var optionTitle      = "Send Derpus to investigate";
            var optionResultText =
                "Derpus SPRINTS towards the schoolhouse, the wagon bouncing behind him. He always wanted to learn to read! Alas, the teacher explains to him that they don't have any room for him. The best she can do is offer some food if he agrees to be a guest speaker. Derpus agrees and speaks to the children about the importance of staying in school using himself as an example.";

            var reward = new Reward();

            reward.AddPartyGain(PartySupplyTypes.Food, 10);

            var penalty = new Penalty();

            var travelManager = Object.FindObjectOfType <TravelManager>();

            penalty.AddEntityLoss(travelManager.Party.Derpus, EntityStatTypes.CurrentMorale, 10);

            var optionOne = new Option(optionTitle, optionResultText, reward, penalty, EncounterType);

            Options.Add(optionTitle, optionOne);

            optionTitle      = "We don't need any learnin'";
            optionResultText =
                "You decide to pass it by. You swear you catch Derpus staring at it as it fades out of sight.";

            var optionTwo = new Option(optionTitle, optionResultText, EncounterType);

            Options.Add(optionTitle, optionTwo);
        }
Exemplo n.º 18
0
        public void Update(Penalty a)
        {
            DB db = new DB();

            db.Entry(a).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
                // Your code...
                // Could also be before try if you know the exception occurs in SaveChanges
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }
        }
Exemplo n.º 19
0
        public override void Run()
        {
            var klutz = Party.GetRandomCompanion();

            Description = $"While walking along a riverbank, the ground gives out from under {klutz.FirstName()}'s feet and they slide into the water. Some of their gear is lost or ruined!";

            Penalty = new Penalty();

            Penalty.AddEntityLoss(klutz, EntityStatTypes.CurrentMorale, 10);

            Penalty.AddPartyLoss(PartySupplyTypes.Food, 2);
            Penalty.AddPartyLoss(PartySupplyTypes.HealthPotions, 2);

            var fullResultDescription = new List <string> {
                Description + "\n"
            };

            var travelManager = Object.FindObjectOfType <TravelManager>();

            travelManager.ApplyEncounterPenalty(Penalty);

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.EncounterResult, this, fullResultDescription);
        }
        public ActionResult MyProcess()
        {
            List <BookViewModel> myPrcss = new List <BookViewModel>();

            string usrName          = Session["UserID"].ToString();
            List <BookOperation> MP = (from b in Process.BookOperations
                                       where b.UserName == usrName
                                       select b).ToList();

            TimeSpan?interval;
            DateTime?receivingDate, givingDate;
            Penalty  penalty = new Penalty();

            foreach (var item in MP)
            {
                BookViewModel bk = new BookViewModel();
                bk.CategoryName    = item.CategoryName;
                bk.BookName        = item.BookName;
                bk.AuthorName      = item.AuthorName;
                bk.PublisherName   = item.PublisherName;
                bk.UserName        = item.UserName;
                bk.ReceivingDate   = item.ReceivingDate;
                bk.GivingDate      = item.GivingDate;
                bk.PenaltyQuantity = (from i in Process.Penalties
                                      where i.BookOperationId == item.Id
                                      select i.PenaltyQuantity).FirstOrDefault();

                if (bk.GivingDate == null)
                {
                    receivingDate = bk.ReceivingDate;
                    givingDate    = bk.GivingDate;
                    interval      = DateTime.Now - receivingDate;
                    if (interval.Value.Days <= 7)
                    {
                        TempData["notice"] = "";
                    }
                    else
                    {
                        interval = DateTime.Now.AddDays(-7) - (receivingDate);
                        foreach (var i in Process.Penalties)
                        {
                            if (i.BookOperationId == item.Id)
                            {
                                i.PenaltyQuantity  = (double)interval.Value.Days * 0.50;
                                bk.PenaltyQuantity = i.PenaltyQuantity;
                            }
                        }
                        TempData["notice"] += "** " + bk.BookName + "'ı lütfen iade ediniz.7 gün geçmiştir";
                    }
                }
                Process.SaveChanges();
                myPrcss.Add(bk);
            }
            if (myPrcss.Count.Equals(0))
            {
                TempData["notice"] = "Herhangi bir işleminiz bulunmamaktadır.";
            }

            return(View(myPrcss));
        }
Exemplo n.º 21
0
        public static string CiteOccurence(Penalty penalty, IList <Day> history)
        {
            if (penalty.historical.numberOfOccurences == 0)
            {
                return("");
            }
            string result = "This has happened ";

            result += penalty.historical.numberOfOccurences switch
            {
                1 => "once",
                2 => "twice",
                _ => penalty.historical.numberOfOccurences + " times",
            };
            result += ", most recently on ";
            if (penalty.historical.mostRecentGameIndex == -1)
            {
                result += "[deleted]";
            }
            else if (history == null)
            {
                result += penalty.historical.mostRecentGameIndex;
            }
            else
            {
                result += history[penalty.historical.mostRecentGameIndex];
            }
            return(result);
        }
Exemplo n.º 22
0
        public override void Run()
        {
            var chosen = Party.GetRandomCompanion();

            Description =
                $"The party makes camp and it's a pretty uneventful evening until {chosen.FirstName()} decides to cut their own hair. It turns out awful!";

            Reward = new Reward();

            Reward.EveryoneGain(Party, EntityStatTypes.CurrentEnergy, 10);

            Penalty = new Penalty();

            Penalty.AddEntityLoss(chosen, EntityStatTypes.CurrentMorale, 5);

            var fullResultDescription = new List <string> {
                Description + "\n"
            };

            var travelManager = Object.FindObjectOfType <TravelManager>();

            travelManager.ApplyEncounterPenalty(Penalty);
            travelManager.ApplyEncounterReward(Reward);

            var eventMediator = Object.FindObjectOfType <EventMediator>();

            eventMediator.Broadcast(GlobalHelper.EncounterResult, this, fullResultDescription);
        }
Exemplo n.º 23
0
        public async Task Delete_WithValidCrewAndPenalty_ShouldDeletePenalty()
        {
            using (var context = provider.GetService <TimingSiteContext>())
                using (var controller = new HeadRaceTimingSite.Api.Controllers.PenaltyController(mapper, context))
                {
                    Crew dbCrew = new Crew {
                        CrewId = 1, BroeCrewId = 123456
                    };
                    context.Crews.Add(dbCrew);
                    Penalty dbPenalty = new Penalty {
                        PenaltyId = 1
                    };
                    context.Penalties.Add(dbPenalty);
                    dbCrew.Penalties.Add(dbPenalty);
                    context.SaveChanges();

                    var response = await controller.DeleteByCrewAndId(123456, 1).ConfigureAwait(false);

                    var noContentResult = response as NoContentResult;

                    Assert.IsNotNull(noContentResult);
                    Assert.AreEqual(204, noContentResult.StatusCode);
                    Assert.AreEqual(0, dbCrew.Penalties.Count);
                }
        }
Exemplo n.º 24
0
        public async void tapped(object sender, ItemTappedEventArgs e)
        {
            if (fe.FriendID != Constants.me.userid)
            {
                Penalty p       = (Penalty)e.Item;
                bool    confirm = await DisplayAlert("(★ゝω・)b⌒☆", "Have your friend fullfilled his/her penalty?", "Yes", "Not yet");

                if (confirm)
                {
                    await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(new LoadingPage());

                    int ret = await Communications.removePenalty(p.date, p.taskid, fe.FriendID);

                    if (ret > 0)
                    {
                        ps.Remove(p);
                        list.ItemsSource = null;
                        list.ItemsSource = ps;
                        await DisplayAlert("(✿◖◡◗)ノシ", "Success", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Server error!", "Please try again", "Ok");
                    }
                    await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync();
                }
            }
        }
Exemplo n.º 25
0
        private void TranslatePenaltyDictionary(Dictionary <int, PlayerPenaltiesModel> playerPenaltiesModelMap,
                                                out Dictionary <int, List <Penalty> > jamPenaltyMap, out Dictionary <int, List <Penalty> > playerPenaltyMap)
        {
            jamPenaltyMap    = new Dictionary <int, List <Penalty> >(50);
            playerPenaltyMap = new Dictionary <int, List <Penalty> >(28);

            foreach (KeyValuePair <int, PlayerPenaltiesModel> playerPenalty in playerPenaltiesModelMap)
            {
                int penaltyCount = 1;
                foreach (PenaltyModel penaltyModel in playerPenalty.Value.Penalties)
                {
                    Jam jam = _jams.First(j => j.IsFirstHalf == penaltyModel.IsFirstHalf && j.JamNumber == penaltyModel.JamNumber);
                    if (!jamPenaltyMap.ContainsKey(jam.ID))
                    {
                        jamPenaltyMap[jam.ID] = new List <Penalty>();
                    }
                    if (!playerPenaltyMap.ContainsKey(playerPenalty.Key))
                    {
                        playerPenaltyMap[playerPenalty.Key] = new List <Penalty>();
                    }
                    Penalty penalty = new Penalty
                    {
                        PlayerID      = playerPenalty.Key,
                        PenaltyCode   = penaltyModel.PenaltyCode,
                        PenaltyNumber = penaltyCount,
                        JamID         = jam.ID,
                        MatchingKey   = penaltyModel.SpecificKey
                    };
                    penaltyCount++;
                    jamPenaltyMap[jam.ID].Add(penalty);
                    playerPenaltyMap[playerPenalty.Key].Add(penalty);
                }
            }
        }
Exemplo n.º 26
0
	public void Spawn(MinionType _type)
	{
		//Initialize variables
		m_Type = _type;

		m_Animator.SetBool ("NoFaith", false);
		m_Animator.SetInteger ("Type", (int)_type);


		m_Penalty = AudienceManager.Instance.GetRandomPenalty ();
		//Get cur limits
		AudienceManager.Instance.GetMoneyLimits (m_Type, out m_MinMoney, out m_MaxMoney);
		AudienceManager.Instance.GetFaithLimits (m_Type, out m_MinFaith, out m_MaxFaith);
		AudienceManager.Instance.GetWillLimits (m_Type, out m_MinWill, out m_MaxWill);

		//Round values to integers
		m_Money = Mathf.Floor (Random.Range (m_MinMoney, m_MaxMoney)+GameManager.Instance.GetMoneyBonus(m_Type));
		m_Faith = Mathf.Floor (Random.Range (m_MinFaith, m_MaxFaith)+GameManager.Instance.GetFaithBonus(m_Type));
		m_Will = Mathf.Floor (Random.Range (m_MinWill, m_MaxWill)+GameManager.Instance.GetWillBonus(m_Type));

		//Assign values to the text TODO: add icons?
		m_MoneyText.text = m_Money.ToString();
		m_FaithText.text = m_Faith.ToString();
		m_WillText.text = m_Will.ToString ();
		m_PenaltyIcon.sprite = GameManager.Instance.GetPenaltyICon (m_Penalty);

		MoveToFront ();
	}
Exemplo n.º 27
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (JWToken.Length != 0)
            {
                hash ^= JWToken.GetHashCode();
            }
            if (reservation_ != null)
            {
                hash ^= Reservation.GetHashCode();
            }
            if (guestId_ != null)
            {
                hash ^= GuestId.GetHashCode();
            }
            if (penalty_ != null)
            {
                hash ^= Penalty.GetHashCode();
            }
            if (DaysBeforeReservationStart != 0)
            {
                hash ^= DaysBeforeReservationStart.GetHashCode();
            }
            if (RequestingParty.Length != 0)
            {
                hash ^= RequestingParty.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 28
0
        private async void RefreshChildEntities(Penalty penalty)
        {
            _entityRefreshNeeded = false;

            if (ReferenceEquals(penalty, null))
            {
                return;
            }

            if (ReferenceEquals(penalty.parties, null))
            {
                penalty.parties      = new Party[0];
                _entityRefreshNeeded = true;
            }
            else
            {
                var partyList = new List <Party>();

                // Try a cascading series of attempts to get a matching entity
                foreach (var party in penalty.parties)
                {
                    var prty = await RefreshParty(party);

                    partyList.Add(prty);
                }

                penalty.parties = partyList.ToArray();
            }

            if (_entityRefreshNeeded)
            {
                await AddOrUpdateAsync(penalty);
            }
        }
Exemplo n.º 29
0
        public void SendPenaltyDelete(Penalty penalty)
        {
            var command = SyncCommandHelper.DeletePenalty(penalty);

            Debug.WriteLine(">> Sending penalty update: " + command);
            this.SendCommand(command);
        }
        public IList <Penalty> ShowPenalties(int skaterNumber)
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand($"select * from Penalty WHERE SkaterNumber = @skaterNumber", connection);
                    command.Parameters.AddWithValue("@skaterNumber", skaterNumber);
                    command.ExecuteNonQuery();

                    SqlDataReader  reader    = command.ExecuteReader();
                    List <Penalty> penalties = new List <Penalty>();
                    while (reader.Read())
                    {
                        Penalty penalty = new Penalty();
                        penalty.PenaltyId    = Convert.ToInt32(reader["PenaltyId"]);
                        penalty.PenaltyType  = Convert.ToString(reader["PenaltyType"]);
                        penalty.SkaterNumber = Convert.ToInt32(reader["SkaterNumber"]);
                        penalties.Add(penalty);
                    }
                    return(penalties);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
        public IList <Penalty> ShowAllPenalties()
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command = new SqlCommand("SELECT penaltyId, penaltyType, skaterNumber FROM Penalty", connection);
                    command.ExecuteNonQuery();

                    SqlDataReader  reader    = command.ExecuteReader();
                    List <Penalty> penalties = new List <Penalty>();
                    while (reader.Read())
                    {
                        Penalty penalty = new Penalty();
                        penalty.PenaltyId    = Convert.ToInt32(reader["PenaltyId"]);
                        penalty.PenaltyType  = Convert.ToString(reader["PenaltyType"]);
                        penalty.SkaterNumber = Convert.ToInt32(reader["SkaterNumber"]);
                        penalties.Add(penalty);
                    }
                    return(penalties);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw;
            }
        }
Exemplo n.º 32
0
 public Penalty addPenalty(long employee, string Detail, long amount, long months, long penaltyTypeId, DateTime date)
 {
     Penalty result = null;
     try
     {
         using (var repository = new MainRepository(new AppContext("PostgresConnection")))
         {
             var penalty = new PenaltyEntity()
             {
                 Amount = amount,
                 Date = date,
                 Description = Detail,
                 EmployeeId = employee,
                 PenaltyTypeId = penaltyTypeId,
                 PenaltyPrice = repository.PenaltyTypes.getPriceById(penaltyTypeId),
             };
             penalty = repository.Penalties.Add(penalty);
             repository.Complete();
             result = new Penalty()
             {
                 id = penalty.Id,
                 amount = penalty.Amount,
                 date = penalty.Date,
                 detail = penalty.Description,
                 employee = penalty.EmployeeId,
                 type = penalty.PenaltyTypeId,
                 typeName = penalty.fkpenalty_type.name,
                 penaltyPrice =penalty.PenaltyPrice
             };
         }
     }
     catch (Exception e)
     {
         throw validateException(e);
     }
     return result;
 }
Exemplo n.º 33
0
        public Penalty selectPenalty(long idRecess)
        {
            Penalty result = null;
            try
            {
                using (var repository = new MainRepository(new AppContext("PostgresConnection")))
                {
                    PenaltyEntity penalty = repository.Penalties.Get(idRecess);

                    if (penalty != null)
                    {
                        result = new Penalty()
                        {
                            id = penalty.Id,
                            amount = penalty.Amount,
                            date = penalty.Date,
                            detail = penalty.Description,
                            employee = penalty.EmployeeId,
                            type = penalty.PenaltyTypeId,
                            typeName = penalty.fkpenalty_type.name,
                            penaltyPrice = penalty.PenaltyPrice
                        };
                    }
                    else
                    {
                        throw validateException(penalty != null ? App_LocalResoures.Errors.penaltyInactive : App_LocalResoures.Errors.inexistentPenalty);
                    }
                }
            }
            catch (Exception e)
            {
                throw validateException(e);
            }
            return result;
        }
Exemplo n.º 34
0
        static void PenaltyAdd(IPEndPoint endpoint)
        {
            lock (penalties)
            {
                Penalty p = penalties.FirstOrDefault(x => EndpointEquals(x.endpoint, endpoint));

                if (p == null)
                {
                    p = new Penalty() { endpoint = endpoint, penalty = 0 };
                    penalties.Add(p);
                }

                p.lastActive = DateTime.Now;
                p.penalty += slotTime;
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// Returns the Penalties for a flight on a Parcours (Forbidden Zones only)
        /// </summary>
        /// <param name="parcours"></param>
        /// <param name="flight"></param>
        /// <returns></returns>
        public static PenaltyCollection calculateForbiddenZonePenalties(Parcours parcours, Flight flight)
        {
            bool lastPointWasOffTrack = false;
            bool finishingGatePassed = false;
            List<GpsPoint> penaltyPoints = new List<GpsPoint>();

            List<List<GpsPoint>> penaltyPointsList = new List<List<GpsPoint>>();

            for (int i = 0; i< flight.Track.Count-1; i++)
            {
                if(!finishingGatePassed)
                {
                    TrackPoint trackpoint = flight.Track[i];
                    for(int j = 0; j<4;j++)
                    {
                        // ToDo: get gate
                        //if(Common.gatePassed(parcours.Gates[j,1] ,trackpoint, flight.Track[i+1]))
                        //{
                        //    finishingGatePassed = true;
                        //    break;
                        //}
                        if (parcours.IsPointOffTrack(trackpoint))
                        {
                            lastPointWasOffTrack = true;
                            penaltyPoints.Add(trackpoint);
                        }
                        else
                        {
                            if (lastPointWasOffTrack)
                            {
                                penaltyPointsList.Add(penaltyPoints);
                                penaltyPoints = new List<GpsPoint>();
                            }
                            lastPointWasOffTrack = false;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            PenaltyCollection penalties = new PenaltyCollection();
            foreach (List<GpsPoint> penaltySequence in penaltyPointsList)
            {
                int durance = penaltySequence.Count;
                Rules.RestrictedAreaDuration restrictedAreaDuration;

                if(durance <= 2)
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.ZeroToTwo;
                else if(durance >=3 && durance <= 4)
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.ThreeToFour;
                else if(durance >=5 && durance <= 6)
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.FiveToSix;
                else if(durance >=7 && durance <= 8)
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.SevenToEight;
                else if(durance >=9 && durance <=10)
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.NineToTen;
                else
                    restrictedAreaDuration = Rules.RestrictedAreaDuration.MoreOrEqEleven;

                Penalty newPenalty = new Penalty();
                // ToDo: assign penalty point, comment, etc.
                penalties.Add(newPenalty);
            }
            return penalties;
        }
Exemplo n.º 36
0
	private void ApplyPenalty(Penalty _penalty,int _idx)
	{
		switch(_penalty)
		{
			case Penalty.LoseInvestment_Small: //retrieve a small amount of money
				GameManager.Instance.SpendMoney(m_InvestmentToLoseSmall,true);
				//TODO: penalty FX
			break;
			case Penalty.LoseInvestment_Big: //retrieve big amount of money
				GameManager.Instance.SpendMoney(m_InvestmentToLoseBig,true);
				//TODO: penalty FX
			break;

			case Penalty.Difamation_Small: //remove -1 will to 1 random minions
				m_Minions[_idx].m_DifamationFx.Play(true);
				DecreaseWillToARandomMinion(_idx);
			break;
			case Penalty.Difamation_Big: //remove -1 will to all minions
				m_Minions[_idx].m_DifamationFx.Play(true);
				DecrementWill(_idx);
			break;

			case Penalty.Blasfemy_Small: //add a small amount of rage to the GOD
				BossManager.Instance.penaltyGodStep(m_BlasfemyRageSmall);
			break;
			case Penalty.Blasfemy_Big: //add a big amount of rage to the GOD
				BossManager.Instance.penaltyGodStep(m_BlasfemyRageBig);
			break;

			case Penalty.Loot_Small: //remove 1 upgrade to a random statue if possible
				RemoveRandomUpgrades();
			break;
			case Penalty.Loot_Big: //remove 1 upgrade to all statues if possible
				RemoveRandomUpgrades(true);
			break;
		}
	}
Exemplo n.º 37
0
 public void Add(Penalty item)
 {
     items.Add(item);
 }
Exemplo n.º 38
0
	public Sprite GetPenaltyICon(Penalty _penalty)
	{
		return m_PenaltyIcons [(int)_penalty];
	}
Exemplo n.º 39
0
 public void Remove(Penalty item)
 {
     items.Remove(item);
 }
Exemplo n.º 40
0
 public bool Contains(Penalty item)
 {
     return items.Contains(item);
 }