/// <summary> /// Initializes a new instance of the <see cref="PartyView"/> class. /// </summary> public PartyView() { this.InitializeComponent(); this.partyVM = new PartyViewModel(new NavigationService()); this.DataContext = this.partyVM; }
public PartyList() { this.InitializeComponent(); conn = new Connection().GetConnection(); viewModel = new PartyViewModel(); parties = viewModel.PartyList(); }
public LedgerParty() { this.InitializeComponent(); conn = new Connection().GetConnection(); viewModel = new PartyViewModel(); ledgers = viewModel.PartyLedgerList(); }
public IActionResult New(PartyViewModel party) { if (!ModelState.IsValid) { return(View()); } try { Party newParty = new Party { Abbreviation = party.Abbreviation, Name = party.Name, Leader = party.Leader }; partyCollection.CreateParty(newParty); return(RedirectToAction("Index", "Party")); } catch (CreatingPartyFailedException exception) { ModelState.AddModelError("", exception.Message); return(View()); } }
public IHttpActionResult AddEditPartyMaster(PartyViewModel model) { try { if (!_IMaster_Repository.IsPartyExist(model.PartyCode, model.PartyName, model.MobNo1, model.MobNo2)) { bool status = _IMaster_Repository.InsertPartyMaster(model); if (status) { return(Ok(model.PartyCode != 0 ? "Successfully updated" : "Successfully added")); } else { return(BadRequest("Opps! Something problem in your data")); } } else { return(BadRequest(model.PartyName + " certificate is already exist")); } } catch (Exception ex) { return(BadRequest("Opps! Something went wrong")); } }
public JournalAdd() { this.InitializeComponent(); conn = new Connection().GetConnection(); conn.CreateTable <Journal>(); viewModel = new JournalViewModel(); accountVM = new AccountViewModel(); partyVM = new PartyViewModel(); typeVM = new JournalTypeViewModel(); settings = new SettingsViewModel(); LoadPage(); // Testing JSON Operation Dictionary <int, int> data = new Dictionary <int, int>() { { 1, 2 }, { 3, 4 } }; string abc = JsonConvert.SerializeObject(data, Formatting.Indented); Debug.WriteLine("###################################################"); Debug.WriteLine(abc.ToString()); Dictionary <int, int> returnData = JsonConvert.DeserializeObject <Dictionary <int, int> >(abc); Debug.WriteLine("###################################################"); foreach (KeyValuePair <int, int> acc in returnData) { Debug.WriteLine("Key = {0}, Value = {1}", acc.Key, acc.Value); } }
public IHttpActionResult Get(string id) { var party = DbContext.Parties.Find(id); var viewModel = new PartyViewModel(party); return(Ok(viewModel)); }
public PartyAdd() { this.InitializeComponent(); conn = new Connection().GetConnection(); conn.CreateTable <Party>(); viewModel = new PartyViewModel(); subtypeViewModel = new PartySubtypeViewModel(); PageLoad(); }
public static MvcHtmlString CreateParty(this HtmlHelper html, PartyViewModel party, string actionName, string controllerName) { TagBuilder ul = new TagBuilder("a"); ul.SetInnerText(party.Title); ul.MergeAttribute("href", String.Concat("/", controllerName, "/", actionName, "/", party.Id)); ul.MergeAttribute("data-toggle", "tooltip"); ul.MergeAttribute("title", String.Concat("Дата: ", party.Date.ToShortDateString(), ", место: ", party.Location)); return(new MvcHtmlString(ul.ToString())); }
public void CanGetPartyById() { // Expected Result Party expected = fakePartyRepository._fakeRepository.First(); // Actual Result PartyViewModel _vm = _partyServices.GetPartyById(123456); Party result = PartyViewModel.ToDataModel(_vm); // Assert expected.Should().BeEquivalentTo(result); }
public async Task <ActionResult> UpdateParty(PartyViewModel vModel) { QueryParty partyRepo = new QueryParty(context); string userId = User.Identity.GetUserId(); // should be creating aparty with a party ID ???? Party party = await partyRepo.PartyByIdAsync(vModel.PartyId, userId); return(RedirectToAction("Index", new { id = vModel.PartyId })); }
public void CanGetAllParties() { // Expected Result ICollection <Party> areas = fakePartyRepository._fakeRepository.Where(x => x.Dormant == false).ToList(); ICollection <PartyViewModel> expected = areas.Select(x => PartyViewModel.ToViewModel(x)).ToList(); // Actual Result ICollection <PartyViewModel> result = _partyServices.GetAllParties(); // Assert expected.Should().BeEquivalentTo(result); }
public void CanDeleteParty() { //Delete Party _partyServices.DeleteParty(123456); // Actual Result PartyViewModel _vm = _partyServices.GetPartyById(123456); Party resultParty = PartyViewModel.ToDataModel(_vm); bool result = resultParty.Dormant; // Assert result.Should().Equals(true); }
public void SwitchPartyTypeTest2() { Diagram diagram = new Diagram(); Party p = new Party(Party.PartyType.Object, "t:T"); diagram.Parties.Add(p); PartyViewModel pvm = new PartyViewModel(diagram, p); pvm.SwitchPartyType(); Assert.AreEqual(Party.PartyType.Actor, p.Type); }
public async Task <IActionResult> UpdateParty(PartyViewModel party) { try { await _partyServices.UpdateParty(party); return(Ok()); } catch (Exception e) { return(BadRequest(e)); } }
public void CanAddParty() { //Create Additonal Party Party expected = fakePartyRepository.GenerateAdditionalParty(); PartyViewModel _newParty = PartyViewModel.ToViewModel(expected); //Add Party _partyServices.AddParty(_newParty); // Actual Result PartyViewModel _vm = _partyServices.GetPartyById(654321); Party result = PartyViewModel.ToDataModel(_vm); // Assert expected.Should().BeEquivalentTo(result); }
// GET: Parties/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var party = new PartyViewModel { Party = _context.Parties.Single(p => p.Id == id), Characters = new List <Character>(_context.Characters.ToList()) }; return(View(party)); }
public void CanUpdateParty() { //Create Updated Party Party updatedParty = fakePartyRepository.GenerateUpdatedParty(); PartyViewModel _updatedParty = PartyViewModel.ToViewModel(updatedParty); //Update Party _partyServices.UpdateParty(_updatedParty); // Expected Result Party expected = updatedParty; // Actual Result PartyViewModel _vm = _partyServices.GetPartyById(123456); Party result = PartyViewModel.ToDataModel(_vm); // Assert expected.Should().BeEquivalentTo(result); }
public ActionResult Delete(PartyViewModel PartyViewModel) { if (ModelState.IsValid) { var deletresult = PartiesService.DeleteCaseDefect(PartyViewModel.CaseID, PartyViewModel.PartyID, (PartyTypes)PartyViewModel.PartyType); // return JavaScript("$(document).trigger('Parties:DeleteSuccefull');"); if (deletresult == DeleteDefectStatus.Deleted) { ViewBag.SavedDelete = true; return(CPartialView(PartyViewModel).WithSuccessMessages(JIC.Base.Resources.Messages.OperationCompletedSuccessfully)); } else { return(CPartialView(PartyViewModel).WithErrorMessages(JIC.Base.Resources.Messages.OperationNotCompleted)); } } return(CPartialView(PartyViewModel).WithErrorMessages(JIC.Base.Resources.Messages.OperationNotCompleted)); }
public static PartyViewModel Detach(Party party) { PartyViewModel partyviewmodel = new PartyViewModel(); partyviewmodel.PartyId = party.PartyId; partyviewmodel.PartyName = party.PartyName; partyviewmodel.PartyAddress = party.PartyAddress; partyviewmodel.PartyType = party.PartyType; partyviewmodel.CompanyId = party.CompanyId; partyviewmodel.BranchId = party.BranchId; partyviewmodel.ContactNo = party.ContactNo; partyviewmodel.GSTINNo = party.GSTINNo; partyviewmodel.Status = party.Status; partyviewmodel.CreatedBy = party.CreatedBy; partyviewmodel.CreatedOn = party.CreatedOn; partyviewmodel.UpdatedBy = party.UpdatedBy; partyviewmodel.UpdatedOn = party.UpdatedOn; partyviewmodel.StateId = party.StateId; return(partyviewmodel); }
public SequenceDiagramColumnView(SequenceDiagramView parent, PartyViewModel partyVM) { this.CanBeFocused = false; // Create the party view and add it to this column view. PartyView = new PartyView { ViewModel = partyVM }; AnchorsProperty.SetValue(PartyView, Anchors.Left | Anchors.Top | Anchors.Right); Children.Add(PartyView); // Create the lifeline view and add it to this column view. LifeLineView = new LifeLineView(); MarginsProperty.SetValue(LifeLineView, new Margins(0, PartyView.PreferredHeight + 10, 0, 0)); Children.Add(LifeLineView); // Set up viewmodel subscription. parent.ViewModelChanged.Select(vm => vm.StackVM) .Subscribe(stackVM => LifeLineView.ViewModel = stackVM.CreateLifeLineForParty(partyVM)); }
public async Task <ActionResult> Index(int id, int partyId) { QueryCases caseRepo = new QueryCases(context); //PartyTypeRepository pTypeRepo = new PartyTypeRepository(context); QueryCityTax cityTaxRepo = new QueryCityTax(context); QueryFilingStatus filingStatusRepo = new QueryFilingStatus(context); string userId = User.Identity.GetUserId(); Case aCase = await caseRepo.CaseByIdAsync(id, userId); Party party = aCase.Parties.Where(p => p.Id == partyId).FirstOrDefault(); PartyViewModel VM = new PartyViewModel(party); VM.CaseMenu = new CaseMenuViewModel(aCase, "Party"); VM.FilingStatuses = filingStatusRepo.GetFilingStatuses(); VM.CityTaxes = cityTaxRepo.GetCityTaxTypes(); return(View(VM)); }
public IActionResult Edit(int id, PartyViewModel model) { Party party = partyCollection.GetPartyByID(id); ViewBag.Party = party;; if (ModelState.IsValid) { try { party.Abbreviation = model.Abbreviation; party.Name = model.Name; party.Leader = model.Leader; party.Save(); return(RedirectToAction("Index", "Party")); } catch (UpdatingPartyFailedException) { ModelState.AddModelError("", "Editing Party failed, Try again."); return(RedirectToAction("Index", "Party")); } } return(View()); }
public async Task AddParty(PartyViewModel party) { await _partyRepository.AddParty(PartyViewModel.ToDataModel(party)); }
public async Task UpdateParty(PartyViewModel party) { await _partyRepository.UpdateParty(PartyViewModel.ToDataModel(party)); }
public void OnNavigatedFrom(NavigationContext navigationContext) { this.eventAggregator.Unsubscribe<SaveEvent>(this.Save); this.eventAggregator.Unsubscribe<EntitySelectedEvent>(this.EntitySelected); this.Party = new PartyViewModel(this.eventAggregator); }
public PartyViewModel GetPartyById(int partyId) { return(PartyViewModel.ToViewModel(_partyRepository.GetParty(partyId))); }
/// <summary> /// Determine winning party, count votes for candidate in area /// </summary> /// <param name="electionId">Unique Election Id</param> /// <returns></returns> public ResultsViewModel GetElectionResult(int electionId) { // get Election to be calculated Election election = _electionServices.GetElection(electionId); // get list of votes cast for election ICollection <Vote> allVotes = _voteRepository.GetVotesWithElectionId(electionId); // instantialise list of votes that have not been spoilt ICollection <Vote> unSpoiltVotes = new List <Vote>(); int spoiltNumber = 0; // if vote has been spoilt, add to count // else add to list foreach (var vote in allVotes) { if (vote.Candidate != null) { unSpoiltVotes.Add(vote); } else { spoiltNumber = spoiltNumber + 1; } } // group votes by Area var groupedVotes = unSpoiltVotes.GroupBy(x => x.Candidate.Area); // get list of all votes ICollection <Area> areasInElection = groupedVotes.Select(x => x.Key).ToList(); ICollection <AreaResultsViewModel> results = new List <AreaResultsViewModel>(); // calc election result depending on Election Type switch (election.ElectionType) { case ElectionType.FirstPastThePost: foreach (Area area in areasInElection) { if (area != null) { results.Add(CalcFirstPastThePostResult(groupedVotes.Where(x => x.Key == area).Single().ToList(), area)); } } break; case ElectionType.Preference: foreach (Area area in areasInElection) { results.Add(CalcPreferenceVoteResult(groupedVotes.Where(x => x.Key == area).Single().ToList())); } break; default: throw new Exception("Invalid ElectionType for Election in the GetElectionResult method"); } // empty list of candidates var winningCandidateList = new List <CandidateViewModel>(); foreach (var area in results) { // candidates must have majority of votes if (area.CandidatesInArea.First().Votes != area.CandidatesInArea.ElementAt(1).Votes) { // get first candidate in each area, as they have top votes winningCandidateList.Add(area.CandidatesInArea.First()); } } // group by party(id) and orderby number of winning candidates var partiesByCandidateCount = winningCandidateList.GroupBy(x => x.PartyId).OrderByDescending(x => x.Count()); List <PartyViewModel> partyList = new List <PartyViewModel>(); // iterate over all the parties and count total number of seats each party has foreach (var candidate in winningCandidateList) { if (partyList.Any(x => x.PartyId == candidate.PartyId)) { foreach (var item in partyList.Where(w => w.PartyId == candidate.PartyId)) { item.Seats = item.Seats + 1; } } else { candidate.Party.Seats = 1; partyList.Add(candidate.Party); } } partyList = partyList.OrderByDescending(x => x.Seats).ToList(); PartyViewModel party = new PartyViewModel(); // check if there's more than 1 party if (partiesByCandidateCount.Count() > 1) { // if the top 2 parties have the same number of seats if (partiesByCandidateCount.First().Count() == partiesByCandidateCount.ElementAt(1).Count()) { // if 1st n 2nd have same number of votes, then there's no majority party = new PartyViewModel { PartyName = "No majority!" }; } else { // get winning party party = partyList.FirstOrDefault(); } } else if (partiesByCandidateCount.Count() == 0) { // if there's no majority in each area, then there's no goverment party = new PartyViewModel { PartyName = "No majority!" }; } else { // get winning party party = partyList.FirstOrDefault(); } var toReturn = new ResultsViewModel() { Areas = results, SpoiltVoteCount = spoiltNumber, LeadingParty = party, Parties = partyList }; return(toReturn); }
public LifeLineViewModel(MessageStackViewModel messageStackViewModel, PartyViewModel party) { MessageStackVM = messageStackViewModel; PartyVM = party; }
public void Sorting() { this.SelectedParty = null; }
private void Save(SaveEvent saveEvent) { this.entityService.ExecuteAsync( () => this.entityService.Create(this.Party.Model()), () => { this.Party = new PartyViewModel(this.eventAggregator); }, string.Format(Message.EntityAddedFormatString, "Party"), this.eventAggregator); }
public IActionResult Participants() { PartyViewModel partyViewModel = new PartyViewModel(service.ListParties(), service.ListParticipants()); return(View("Participants", partyViewModel)); }
public ICollection <PartyViewModel> GetAllParties() { ICollection <Party> parties = _partyRepository.GetAllParties(); return(parties.Select(x => PartyViewModel.ToViewModel(x)).ToList()); }