예제 #1
0
        public ActionResult ReallocatePrisoner(int?id)
        {
            if (id != null)
            {
                Prisoners  prisoner  = _db.Prisoners.FirstOrDefault(x => x.Prisoner_Id == id.Value);
                Judgements judgement = _db.Judgements.FirstOrDefault(x => x.FK_Judgements_Prisoners_Id == id);

                var model = new AllocationViewModel()
                {
                    Prisoner_Id        = id.Value,
                    CategoryOfCrime_Id = judgement.FK_Judgements_CategoriesOfCrimes_Id,
                    Sex = prisoner.PrisonerSurname
                };



                model.Cells = from c in _db.Cells
                              join branch in _db.Branches
                              on c.FK_Cells_Branch equals branch.Branch_id
                              join branchSex in _db.BranchesSex
                              on branch.Branch_id equals branchSex.FK_BranchesSex_Branches_Id
                              where branchSex.FK_BranchesSex_CategoriesOfCrimes_Id == judgement.FK_Judgements_CategoriesOfCrimes_Id && c.IsEmpty &&
                              branchSex.Sex == prisoner.Sex && c.Cell_Id != ReleasePrisonerClass.Placeholder
                              select c;

                if (model.Cells.Any() == false)
                {
                    TempData["alertMessage"] = "Brak dostępnych cel";
                    return(RedirectToAction("GetPrisoners", "Prisoners"));
                }
                ViewBag.CelList = new SelectList(model.Cells, "Cell_Id", "Cell_Id");
                return(View(model));
            }
            return(HttpNotFound());
        }
예제 #2
0
        public ActionResult EditPrisoner(Prisoners prisoner)
        {
            var id = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                var history = new ChangesHistory()
                {
                    Worker_Id = id,
                    Date      = DateTime.Now.Date
                };
                _db.Entry(prisoner).State = EntityState.Modified;

                var prisonerChangesHistory = new PrisonerChangesHistory()
                {
                    PrisonerName    = prisoner.PrisonerName,
                    PrisonerSurname = prisoner.PrisonerSurname,
                    Pesel           = prisoner.Pesel,
                    FK_PrisonerChangesHistory_Prisoner_Id = prisoner.Prisoner_Id,
                    Sex = prisoner.Sex,
                    FK_PrisonerChangesHistory_ChangesHistory_Id = history.Record_Id
                };

                _db.ChangesHistory.Add(history);
                _db.PrisonerChangesHistory.Add(prisonerChangesHistory);
                _db.SaveChanges();
                return(RedirectToAction("GetPrisoners", "Prisoners"));
            }
            return(View(prisoner));
        }
예제 #3
0
        public ActionResult AllocatePrisoner(int?id)
        {
            var model = new AllocationViewModel();

            if (id != null)
            {
                model.Prisoner_Id = id.Value;

                Prisoners prisoner = _db.Prisoners.FirstOrDefault(x => x.Prisoner_Id == id);

                model.Sex = prisoner.Sex;

                Judgements judgement = _db.Judgements.FirstOrDefault(x => x.FK_Judgements_Prisoners_Id == id);
                model.CategoryOfCrime_Id = judgement.FK_Judgements_CategoriesOfCrimes_Id;

                model.Cells = from c in _db.Cells
                              join o in _db.Branches
                              on c.FK_Cells_Branch equals o.Branch_id
                              join x in _db.BranchesSex
                              on o.Branch_id equals x.FK_BranchesSex_Branches_Id
                              where x.FK_BranchesSex_CategoriesOfCrimes_Id == judgement.FK_Judgements_CategoriesOfCrimes_Id && c.IsEmpty &&
                              x.Sex == prisoner.Sex && c.Cell_Id != ReleasePrisonerClass.Placeholder
                              select c;

                ViewBag.CelList = new SelectList(model.Cells, "Cell_Id", "Cell_Id");
                return(View(model));
            }
            return(HttpNotFound());
        }
예제 #4
0
        private void ParsePopulationLine(string data)
        {
            data = data.Trim();
            var pop      = Convert.ToInt32(data.Substring(0, data.IndexOf(' ')));
            var race     = data.Substring(data.IndexOf(' ') + 1);
            var thisRace = World.GetAddRace(race);

            if (race.Contains(" prisoner"))
            {
                if (Prisoners.ContainsKey(thisRace))
                {
                    Prisoners[thisRace]++;
                }
                else
                {
                    Prisoners.Add(thisRace, pop);
                }
            }
            else if (race.Contains(" outcast"))
            {
                if (Outcasts.ContainsKey(thisRace))
                {
                    Outcasts[thisRace]++;
                }
                else
                {
                    Outcasts.Add(thisRace, pop);
                }
            }
            else
            {
                if (Population.ContainsKey(thisRace))
                {
                    Population[thisRace] += pop;
                }
                else
                {
                    Population.Add(thisRace, pop);
                }
            }
        }
예제 #5
0
        public MainWindowViewModel()
        {
            //var rep = new txt();
            var rep = new SqlRep();
            var ik  = new IK {
                Title = "test"
            };
            var p = new Prisoner()
            {
                Name = "test", Number = "123", CountMonth = 1
            };

            //rep.Add(p);
            // rep.Save();


            Prisoners   = rep.GetALL();
            IsPrisoners = Prisoners
                          .Where(q => q.isPrisoner())
                          .ToList();
            IsnotPrisoners = Prisoners
                             .Where(q => !q.isPrisoner())
                             .ToList();
        }
예제 #6
0
        public ActionResult AddPrisoner(PrisonerViewModel model)
        {
            var list = _db.CategoriesOfCrimes.ToList();

            ViewBag.KatList = new SelectList(list, "CategoryOfCrime_Id", "NameOfCategory");


            if (ModelState.IsValid)
            {
                var prisoner = new Prisoners
                {
                    PrisonerName    = model.PrisonerName,
                    PrisonerSurname = model.PrisonerSurname,
                    Pesel           = model.Pesel,
                    Sex             = model.Sex
                };


                var wyrok = new Judgements
                {
                    FK_Judgements_CategoriesOfCrimes_Id = model.CategoryOfCrime_Id,
                    FK_Judgements_Prisoners_Id          = prisoner.Prisoner_Id,
                    TimeOfJudgement = model.Time,
                    StartDate       = model.StartDate
                };


                _db.Prisoners.Add(prisoner);
                _db.Judgements.Add(wyrok);
                _db.SaveChanges();

                return(RedirectToAction("AllocatePrisoner", new { id = prisoner.Prisoner_Id }));
            }

            return(View(model));
        }
예제 #7
0
 public void TearDownTest()
 {
     prisoners = null;
 }
예제 #8
0
 public void SetupTest()
 {
     prisoners = new Prisoners();
 }
예제 #9
0
        public override void Select(MainForm frm)
        {
            if (frm.grpSite.Text == ToString() && frm.MainTab.SelectedTab == frm.tabSite)
            {
                return;
            }
            Program.MakeSelected(frm.tabSite, frm.lstSite, this);

            frm.grpSite.Text = ToString();
            if (IsPlayerControlled)
            {
                frm.grpSite.Text += @" (PLAYER CONTROLLED)";
            }
#if DEBUG
            frm.grpSite.Text += $" - ID: {Id}";
#endif
            frm.grpSite.Show();

            frm.lblSiteName.Text      = ToString();
            frm.lblSiteAltName.Text   = AltName;
            frm.lblSiteType.Text      = SiteType;
            frm.lblSiteCoord.Data     = new Coordinate(Coords);
            frm.lblSiteOwner.Data     = Owner;
            frm.lblSiteParentCiv.Data = Parent;
            frm.lblSiteCurOwner.Data  = CurOwner;
            frm.lblSiteCiv.Data       = Civ;

            var siteMapPath = World.MapPath.Replace("world_map", "site_map-" + Id);
            frm.SiteMapLabel.Visible = File.Exists(siteMapPath);



            frm.grpSiteCreated.Visible = CreatedEvent != null;
            if (CreatedEvent != null)
            {
                frm.lblSiteCreatedBy.Data    = CreatedEvent.Entity_SiteCiv;
                frm.lblSiteCreatedByCiv.Data = CreatedEvent.Entity;
                frm.lblSiteCreatedTime.Data  = CreatedEvent;
                frm.lblSiteCreatedTime.Text  = CreatedEvent.Time.ToString();
            }

            if (Population != null)
            {
                frm.grpSitePopulation.FillListboxWith(frm.lstSitePopulation, Population.Keys, this);
                frm.grpSitePopulation.Text = $"Population ({Population.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSitePopulation.Visible = false;
            }
            frm.grpSiteArtifacts.FillListboxWith(frm.lstSiteArtifacts, CreatedArtifacts);
            frm.grpSiteStructures.FillListboxWith(frm.lstSiteStructures, Structures);
            if (Prisoners != null)
            {
                frm.grpSitePrisoners.FillListboxWith(frm.lstSitePrisoners, Prisoners.Keys, this);
                frm.grpSitePrisoners.Text = $"Prisoners ({Prisoners.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSitePrisoners.Visible = false;
            }
            if (Outcasts != null)
            {
                frm.grpSiteOutcasts.FillListboxWith(frm.lstSiteOutcasts, Outcasts.Keys, this);
                frm.grpSiteOutcasts.Text = $"Outcasts ({Outcasts.Sum(x => x.Value)})";
            }
            else
            {
                frm.grpSiteOutcasts.Visible = false;
            }
            frm.grpSiteInhabitants.FillListboxWith(frm.lstSiteInhabitants, Inhabitants);
            frm.grpSiteEvent.FillListboxWith(frm.lstSiteEvent, Events);


            frm.trvSiteEventCollection.Nodes.Clear();
            if (AbductionEventCollections != null)
            {
                var thisNode = new TreeNode("Abduction");
                foreach (var newNode in AbductionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BattleEventCollections != null)
            {
                var thisNode = new TreeNode("Battle");
                foreach (var newNode in BattleEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (BeastAttackEventCollections != null)
            {
                var thisNode = new TreeNode("Beast Attack");
                foreach (var newNode in BeastAttackEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (DuelEventCollections != null)
            {
                var thisNode = new TreeNode("Duel");
                foreach (var newNode in DuelEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (SiteConqueredEventCollections != null)
            {
                var thisNode = new TreeNode("Site Conquered");
                foreach (var newNode in SiteConqueredEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (TheftEventCollections != null)
            {
                var thisNode = new TreeNode("Theft");
                foreach (var newNode in TheftEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }
            if (InsurrectionEventCollections != null)
            {
                var thisNode = new TreeNode("Insurrection");
                foreach (var newNode in InsurrectionEventCollections.Select(evtcol => new TreeNode(evtcol.ToString())
                {
                    Tag = evtcol
                }))
                {
                    thisNode.Nodes.Add(newNode);
                }
                thisNode.Text += $" ({thisNode.Nodes.Count})";
                frm.trvSiteEventCollection.Nodes.Add(thisNode);
            }


            frm.grpSiteEventCollection.Visible = frm.trvSiteEventCollection.Nodes.Count > 0;

            frm.SetDisplayedItem(this);
        }