Example #1
0
        /// <summary>
        /// Sends confirmation for creating a stakeholder
        /// </summary>
        /// <param name="Supplier">Boolean indicatin whether or not this stakeholder is as supplier</param>
        /// <returns></returns>
        private async Task CreateStakeholderAsync(object isSupplierBool)
        {
            //await IoC.UI.ShowMessage(new MessageBoxDialogViewModel
            //{
            //    Title = "Bevestig aanmaking",
            //    Message = $"Aanmaak van: \t {CustSuppSelected} \nNaam: \t\t {Name} \nBTW-nummer: \t {VATNr} \nGelegeven te: \t {LocationSelected}",
            //    OkText = "OK"

            //});

            // Convert the object to a bool
            var isSupplier = isSupplierBool.Equals("False")? false : true;

            // Create the stakeholder
            var newStakeholder = new Stakeholder
            {
                Name       = Name,
                IsSupplier = isSupplier,
                PhNr       = PhNr,
                VatNr      = VatNr,
                BankAcc    = BankAcc,
            };

            // Save the stakeholder to the database
            await IoC.ClientDataStore.SaveStakeholder(newStakeholder);

            // Reset the form, readying it for a new stakeholder input
            ResetForm();
        }
        public StakeholderContainer(Page page, int index, Stakeholder stakeholder, int id) : base(page)
        {
            StakeholderNameComponent nameComponent = new StakeholderNameComponent(page, index, stakeholder.Name);
            StakeholderRoleComponent roleComponent = new StakeholderRoleComponent(page, index, stakeholder.Role);

            Children.Add(nameComponent);
            Children.Add(roleComponent);
            Log.Debug("Starting shapesheet initing of stakeholdercontainer.");
            Name = "Stakeholder";
            //NameU = "Stakeholder";
            RationallyType = "stakeholder";
            Index          = index;
            Id             = id;


            //locks
            MsvSdContainerLocked = true;

            //Events
            AddAction("addStakeholder", "QUEUEMARKEREVENT(\"add\")", "Add stakeholde", false);
            AddAction("deleteStakeholder", "QUEUEMARKEREVENT(\"delete\")", "Delete stakeholder", false);

            Width = 5.26;

            LinePattern = 0;
            InitStyle();
            if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                Shape.ContainerProperties.ResizeAsNeeded = 0;
                ContainerPadding = 0;
            }
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel       model = Globals.RationallyAddIn.Model;
            StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer);

            VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);
            int        currentIndex      = toChangeComponent.Index;

            StakeholderContainer toChange = (StakeholderContainer)stakeholdersContainer.Children.First(c => c.Index == currentIndex);
            //locate the stakeholder that we are going to swap with
            StakeholderContainer other = (StakeholderContainer)stakeholdersContainer.Children.First(c => c.Index == currentIndex + 1);

            Stakeholder one = model.Stakeholders[currentIndex];

            model.Stakeholders[currentIndex]     = model.Stakeholders[currentIndex + 1];
            model.Stakeholders[currentIndex + 1] = one;

            //update the index of the component and his children
            toChange.SetStakeholderIndex(currentIndex + 1);

            //same, for the other component
            other.SetStakeholderIndex(currentIndex);

            //swap the elements in the view tree
            VisioShape temp = stakeholdersContainer.Children[currentIndex];

            stakeholdersContainer.Children[currentIndex]     = stakeholdersContainer.Children[currentIndex + 1];
            stakeholdersContainer.Children[currentIndex + 1] = temp;


            RepaintHandler.Repaint();
        }
Example #4
0
        public void CalculatePaymentMappings(Party party)
        {
            party.Stakeholders.ForEach(s => s.CachedCalculatedDebt = s.Debt);

            while (party.Stakeholders.Any(s => s.CachedCalculatedDebt != 0M))
            {
                Stakeholder highestDebtStakeholder = GetHighestDebtStakeholder(party);

                Stakeholder lowestDebtStakeholder = GetLowestDebtStakeholder(party);

                if (highestDebtStakeholder.Payments == null)
                {
                    highestDebtStakeholder.Payments = new List <Payment>();
                }

                if (Math.Abs(highestDebtStakeholder.CachedCalculatedDebt) <= Math.Abs(lowestDebtStakeholder.CachedCalculatedDebt))
                {
                    SettleHighestDebtStakeholder(highestDebtStakeholder, lowestDebtStakeholder);
                }

                else if (Math.Abs(highestDebtStakeholder.CachedCalculatedDebt) > Math.Abs(lowestDebtStakeholder.CachedCalculatedDebt))
                {
                    SettleLowestDebtStakeholder(highestDebtStakeholder, lowestDebtStakeholder);
                }

                party.Stakeholders.ForEach(s => Console.WriteLine($"{s.Contact.FirstName} {s.Contact.LastName} - {s.CachedCalculatedDebt}"));
            }

            PrintMappings(party);
        }
Example #5
0
        public IEnumerable <Evaluation> FindEvalsForCourse(int id)
        {
            Stakeholder       stakeholder = db.Stakeholders.Where(s => s.CourseID == id).FirstOrDefault();
            List <Evaluation> evaluations = db.Evaluations.Where(e => e.StakeholderID == stakeholder.StakeholderID).ToList();

            return(evaluations);
        }
Example #6
0
        partial void Project_StakeholdersEditSelected_Execute()
        {
            Stakeholder STK = this.Project_Stakeholders.SelectedItem.Stakeholder1;

            this.Stakeholders.SelectedItem = STK;
            this.OpenModalWindow("modalESTK");
        }
Example #7
0
        /// <summary>
        ///     Gets all the devices that a given stakeholder can access.
        /// </summary>
        public IEnumerable <ApplicationAccess> GetAppsAccessibleTo(
            Network network,
            Stakeholder stakeholder,
            Scenario scenario, FsUnitOfWork db)
        {
            // get loginn
            var logins = db.StakeholderLogins
                         .LinqReader.Where(m => m.StakeholderId == stakeholder.Id && m.ScenarioId == scenario.Id);
            var loginIds = logins.Select(m => m.Id);

            // get memberships
            var groups = db.UserGroupMemberships.LinqReader
                         .Where(m => m.MemberId == stakeholder.Id && m.ScenarioId == scenario.Id);
            var groupIds = groups.Select(m => m.GroupId);

            // find by user group membership
            var appAccessByGroupIds = _db.ApplicationAccess
                                      .LinqReader.Where(m => m.UserGroupId != null && m.ScenarioId == scenario.Id)
                                      .ToList()
                                      .Where(m => groupIds.Contains(m.UserGroupId.Value));

            // find by stakeholder assignment
            List <ApplicationAccess> appAccess = this._db.ApplicationAccess
                                                 .LinqReader.Where(m => m.StakeholderLoginId != null && m.ScenarioId == scenario.Id)
                                                 .ToList() // contains can't be processed by underlying provider
                                                 .Where(m => loginIds.Contains(m.StakeholderLoginId.Value))
                                                 .ToList();

            return(appAccess);
        }
        public void Execute(Shape changedShape, string identifier)
        {
            RationallyModel model = Globals.RationallyAddIn.Model;
            //locate the stakeholder(component) to move
            VisioShape toChangeComponent = Globals.RationallyAddIn.View.GetComponentByShape(changedShape);
            int        currentIndex      = toChangeComponent.Index;
            //locate the stakeholder to swap with
            StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer);
            StakeholderContainer  toChange = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex);
            StakeholderContainer  other    = (StakeholderContainer)stakeholdersContainer.Children.First(c => (int)c.Shape.CellsU[VisioFormulas.Cell_Index].ResultIU == currentIndex - 1);

            //swap
            Stakeholder one = model.Stakeholders[currentIndex];

            model.Stakeholders[currentIndex]     = model.Stakeholders[currentIndex - 1];
            model.Stakeholders[currentIndex - 1] = one;

            //update the index of the component and his children
            toChange.SetStakeholderIndex(currentIndex - 1);
            //same, for the other component
            other.SetStakeholderIndex(currentIndex);
            //swap the elements
            VisioShape temp = stakeholdersContainer.Children[currentIndex];

            stakeholdersContainer.Children[currentIndex]     = stakeholdersContainer.Children[currentIndex - 1];
            stakeholdersContainer.Children[currentIndex - 1] = temp;


            RepaintHandler.Repaint();
        }
        private void btnAddBTStakeholder_Click(object sender, EventArgs e)
        {
            String[] names = this.model.GetStakeholderNames();

            frmNameListChooser frm = new frmNameListChooser(names, this.localizer);

            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                String      name        = (String)frm.SelectedItem;
                Stakeholder stakeholder = (Stakeholder)this.model.FindElementByName(name);
                if (this.requirement.Beneficiaries.FindByUniqueID(stakeholder.UniqueID) != null)
                {
                    // [Element already present!]
                    MessageBox.Show(this, this.localizer.GetValue("UserMessages", "elementAlreadyPresent"));
                    return;
                }

                this.requirement.AddBeneficiary(stakeholder);

                ListViewItem lvi = new ListViewItem();
                lvi.Text = stakeholder.Name;
                this.lvBTStakeholders.Items.Add(lvi);
                this.modified = true;
            }

            frm.Dispose();
        }
        public void Execute(Shape s, string identifier)
        {
            RationallyModel model     = Globals.RationallyAddIn.Model;
            VisioShape      component = new VisioShape(Globals.RationallyAddIn.Application.ActivePage)
            {
                Shape = s
            };

            int          index         = component.Index;
            Stakeholder  stakeholder   = model.Stakeholders[index];
            DialogResult confirmResult = MessageBox.Show("Are you sure you want to remove " + stakeholder.Name + "?", "Confirm Deletion", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                Shape shapeToPass;

                if (StakeholderContainer.IsStakeholderContainer(s.Name))
                {
                    shapeToPass = s;
                }
                else //subpart of stakeholder container
                {
                    //trace stakeholders container
                    StakeholdersContainer stakeholdersContainer = (StakeholdersContainer)Globals.RationallyAddIn.View.Children.First(c => c is StakeholdersContainer);
                    //trace the correct stakeholder container
                    StakeholderContainer stakeholderContainer = (StakeholderContainer)stakeholdersContainer.Children.First(c => c is StakeholderContainer && (component.Index == c.Index));

                    shapeToPass = stakeholderContainer.Shape;
                }
                //initiate a delete handler with the container's shape
                shapeToPass.Delete();
            }
        }
        public IActionResult DeleteConfirmed(int id)
        {
            Stakeholder thisStakeholder = stakeholderRepo.Stakeholders.FirstOrDefault(x => x.StakeholderId == id);

            stakeholderRepo.Remove(thisStakeholder);
            return(RedirectToAction("Index"));
        }
        public frmRequirementEditor(Requirement requirement, Model model, Localizer localizer)
        {
            InitializeComponent();

            this.requirement = requirement;
            this.model       = model;
            this.localizer   = localizer;

            this.localizer.LocalizeControls(this);

            this.lockModified = true;

            // Details page
            foreach (ReferencedObject refobj in this.requirement.Proponents)
            {
                Stakeholder stakeholder = this.model.GetStakeholder(refobj.UniqueID);
                if (stakeholder != null)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = stakeholder.Name;
                    this.lvPBStakeholders.Items.Add(lvi);
                }
            }

            foreach (ReferencedObject refobj in this.requirement.Beneficiaries)
            {
                Stakeholder stakeholder = this.model.GetStakeholder(refobj.UniqueID);
                if (stakeholder != null)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = stakeholder.Name;
                    this.lvBTStakeholders.Items.Add(lvi);
                }
            }

            foreach (ReferencedObject refobj in this.requirement.MappedUseCases)
            {
                UseCase useCase = (UseCase)this.model.FindElementByUniqueID(refobj.UniqueID);
                if (useCase != null)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = useCase.Name;
                    this.lvMappedOntoUCs.Items.Add(lvi);
                }
            }

            cmbCategory.SelectedIndex         = (Int32)this.requirement.Category;
            cmbImportance.SelectedIndex       = (Int32)this.requirement.Importance;
            cmbStatus.SelectedIndex           = (Int32)this.requirement.Status;
            cmbAcceptanceStatus.SelectedIndex = (Int32)this.requirement.AcceptanceStatus;

            this.UpdateHistoryView();

            this.SetButtons();

            this.lockModified = false;

            this.ImeMode = ImeMode.On;
        }
        /// <summary>
        /// Stores the given stakeholder to the backing data store
        /// </summary>
        /// <param name="stakeholder">The stakeholder to save</param>
        public async Task SaveStakeholder(Stakeholder stakeholder)
        {
            // Add new one
            _dbContext.Stakeholders.Add(stakeholder);

            // Save changes
            await _dbContext.SaveChangesAsync();
        }
Example #14
0
        /// <summary>
        ///     Removes all memberships a given stakeholder may have.
        /// </summary>
        public void RemoveGroupMemberships(Stakeholder stakeholder)
        {
            using (_db.Open())
            {
                RemoveGroupMemberships(stakeholder, _db);

                _db.Commit();
            }
        }
        private void btnRemoveBTStakeholder_Click(object sender, EventArgs e)
        {
            ListViewItem lvi         = lvBTStakeholders.SelectedItems[0];
            Stakeholder  stakeholder = (Stakeholder)this.model.FindElementByName(lvi.Text);

            this.requirement.RemoveBeneficiary(stakeholder);
            this.lvBTStakeholders.Items.Remove(lvi);
            this.modified = true;
        }
Example #16
0
 public IStakeholder Convert(Stakeholder stakeholder)
 {
     using (var convertedStakeholder = DomainLocator.GetStakeholder())
     {
         convertedStakeholder.Object.Name            = stakeholder.Name;
         convertedStakeholder.Object.IsParticipating = stakeholder.IsParticipating;
         return(convertedStakeholder.Object);
     }
 }
Example #17
0
        /// <summary>
        ///     Gets the device connections that a given user can access.
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public IList <DeviceConnection> GetConnectionsAccessibleTo(
            IEnumerable <Device> devices,
            Stakeholder stakeholder,
            Scenario scenario)
        {
            var allConnections = new List <DeviceConnection>();

            using (_db.Open())
            {
                // get login
                var logins = _db.StakeholderLogins
                             .LinqReader.Where(m => m.StakeholderId == stakeholder.Id &&
                                               m.ScenarioId == scenario.Id);

                // get memberships
                var groups = _db.UserGroupMemberships.LinqReader
                             .Where(m => m.MemberId == stakeholder.Id && m.ScenarioId == scenario.Id);

                // get list of group ids
                var identities = groups
                                 .Select(m => m.Id)
                                 .Combine(logins.Select(m => m.Id))
                                 .ToList();

                foreach (Device device in devices)
                {
                    IList <DeviceConnection> targetConnectionDevices = _deviceConnectionService
                                                                       .Where(m => m.DeviceTargetId == device.Id, _db)
                                                                       .ToList();

                    // filter connections
                    foreach (DeviceConnection connection in targetConnectionDevices)
                    {
                        // the infomration provider
                        if (connection.TargetRoleAuthorization != null &&
                            connection.TargetRoleAuthorization.Any())
                        {
                            // determine if role is authorized
                            if (connection.TargetRoleAuthorization
                                .Any(m => identities.Contains(m)))
                            {
                                // authorized
                                allConnections.Add(connection);
                            }
                        }
                        else
                        {
                            // assume all users have access
                            allConnections.Add(connection);
                        }
                    }
                }
            }

            return(allConnections);
        }
Example #18
0
        public Stakeholder Convert(IStakeholder stakeholderBO)
        {
            var convertedStakeholder = new Stakeholder
            {
                Name            = stakeholderBO.Name,
                IsParticipating = stakeholderBO.IsParticipating
            };

            return(convertedStakeholder);
        }
Example #19
0
        /// <summary>
        ///     Adds member to a group type of stakeholder.
        /// </summary>
        /// <param name="userGroup">The parent containing group.</param>
        /// <param name="member">The member of the group.</param>
        public void AddMember(UserGroup userGroup, Stakeholder member)
        {
            Guard.ArgumentNotNull(userGroup, nameof(userGroup));
            Guard.ArgumentNotNull(member, nameof(member));

            // update parent memberships
            var membership = new UserGroupMembership(userGroup, member);

            SetMembership(new[] { membership });
        }
Example #20
0
        private void SettleLowestDebtStakeholder(Stakeholder highestDebtStakeholder, Stakeholder lowestDebtStakeholder)
        {
            highestDebtStakeholder.Payments = highestDebtStakeholder.Payments.AddItem(new Payment
            {
                Ammount = Math.Abs(lowestDebtStakeholder.CachedCalculatedDebt),
                Payer   = highestDebtStakeholder.Contact,
                Payee   = lowestDebtStakeholder.Contact
            });

            highestDebtStakeholder.CachedCalculatedDebt += lowestDebtStakeholder.CachedCalculatedDebt;

            lowestDebtStakeholder.CachedCalculatedDebt -= lowestDebtStakeholder.CachedCalculatedDebt;
        }
Example #21
0
        private Stakeholder GetHighestDebtStakeholder(Party party)
        {
            Stakeholder highestDebtStakeholder = party
                                                 .Stakeholders
                                                 .Aggregate
                                                 (
                (currentMax, s) => (currentMax == null || (s.CachedCalculatedDebt) > currentMax.CachedCalculatedDebt ? s : currentMax)
                                                 );

            Console.WriteLine($"Highest debt stakeholder: {highestDebtStakeholder.Contact.FirstName} {highestDebtStakeholder.Contact.LastName}");

            return(highestDebtStakeholder);
        }
Example #22
0
        private Stakeholder GetLowestDebtStakeholder(Party party)
        {
            Stakeholder lowestDebtStakeholder = party
                                                .Stakeholders
                                                .Aggregate
                                                (
                (currentMin, s) => (currentMin == null || (s.CachedCalculatedDebt) < currentMin.CachedCalculatedDebt ? s : currentMin)
                                                );

            Console.WriteLine($"Lowest debt stakeholder: {lowestDebtStakeholder.Contact.FirstName} {lowestDebtStakeholder.Contact.LastName}");

            return(lowestDebtStakeholder);
        }
 public override void Repaint()
 {
     if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
     {
         UpdateReorderFunctions(Globals.RationallyAddIn.Model.Stakeholders.Count - 1);
         if (Globals.RationallyAddIn.Model.Stakeholders.Count > Index)
         {
             Stakeholder stakeholder = Globals.RationallyAddIn.Model.Stakeholders[Index];
             Text = stakeholder.Role;
         }
     }
     base.Repaint();
 }
Example #24
0
        public void AddStakeholder(string name, string role)
        {
            PleaseWait pleaseWait = new PleaseWait();

            pleaseWait.Show();
            pleaseWait.Refresh();
            Stakeholder stakeholder = new Stakeholder(name, role);

            Globals.RationallyAddIn.Model.Stakeholders.Add(stakeholder);
            Children.Add(new StakeholderContainer(Globals.RationallyAddIn.Application.ActivePage, Globals.RationallyAddIn.Model.Stakeholders.Count - 1, stakeholder, stakeholder.Id));//assumes stakeholder is already in the model
            RepaintHandler.Repaint(this);
            pleaseWait.Hide();
        }
        public async Task OnGetAsync()
        {
            _userFromDb = await _userManager.GetUserAsync(User);

            if (_userFromDb == null)
            {
                RedirectToPage("/Login");
                throw new Exception("User not logged in");
            }

            Stakeholder = await _context.Stakeholder
                          .Where(x => x.IdentityUser.Id == _userFromDb.Id)
                          .FirstOrDefaultAsync();
        }
 public void UpdateModel()
 {
     //if this row represents an existing stakeholder in the model, update it.
     if (Stakeholder != null)
     {
         Stakeholder.Name = StakeholderName.Text;
         Stakeholder.Role = StakeholderRole.Text;
     }
     else
     {
         Stakeholder newStakeholder = new Stakeholder(StakeholderName.Text, StakeholderRole.Text);
         StakeholderIndex = Math.Min(StakeholderIndex, ProjectSetupWizard.Instance.ModelCopy.Stakeholders.Count);
         ProjectSetupWizard.Instance.ModelCopy.Stakeholders.Insert(StakeholderIndex, newStakeholder);
     }
 }
Example #27
0
        public Evaluation FindEvalForStudent(int id)
        {
            IQueryable <Enrollment> enrollments = FindEnrollmentsForCourse(id);
            int         enrollmentID            = enrollments.Where(s => s.StudentID == ParseUserID()).Select(c => c.EnrollmentID).FirstOrDefault();
            Stakeholder stakeholder             = db.Stakeholders.Where(s => s.CourseID == id).FirstOrDefault();
            var         eval = db.Evaluations.Where(e => e.EnrollmentID == enrollmentID).Select(c => c).FirstOrDefault();

            if (eval == null)
            {
                eval = new Evaluation();
                eval.EnrollmentID  = enrollmentID;
                eval.StakeholderID = stakeholder.StakeholderID;
            }
            return(eval);
        }
Example #28
0
        public void Execute(RationallyView view, Shape changedShape)
        {
            VisioShape stakeholderRoleComponent = new VisioShape(view.Page)
            {
                Shape = changedShape
            };

            if (Globals.RationallyAddIn.Model.Stakeholders.Count <= stakeholderRoleComponent.Index)
            {
                return;
            }

            Stakeholder toUpdate = Globals.RationallyAddIn.Model.Stakeholders[stakeholderRoleComponent.Index];

            toUpdate.Role = stakeholderRoleComponent.Text;
        }
Example #29
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Stakeholder = await _context.Stakeholder.FirstOrDefaultAsync(m => m.Id == id);

            if (Stakeholder == null)
            {
                return(NotFound());
            }

            return(Page());
        }
 private async Task <bool> MapInput(Stakeholder stakeholder)
 {
     return(await TryUpdateModelAsync(
                stakeholder,
                "stakeholder",       // Prefix for form value.
                s => s.Type,
                s => s.ProducerType,
                s => s.BuyerType,
                s => s.Organization,
                s => s.State,
                s => s.Country,
                s => s.NumberOfEmployees,
                s => s.ContactPerson,
                s => s.PhoneNumber,
                s => s.Email,
                s => s.Equipment,
                s => s.HowCanYouHelp));
 }