Exemple #1
0
        public ActionResult RemovePartnerPost(int partnershipID, int profileID, string returnUrl)
        {
            var partnership           = _workUnit.PartnershipRepository.GetEntityByID(partnershipID);
            var profile               = _workUnit.ProfileRepository.GetEntityByID(profileID);
            var currentProfile        = CurrentAccount.Profile;
            PartnershipDetail partner = null;

            try {
                partner = _workUnit.PartnershipDetailRepository.Entities
                          .First(x => x.ProfileID == profileID && x.PartnershipID == partnershipID);
                _workUnit.PartnershipDetailRepository.DeleteByID(partner.PartnershipDetailID);
            }
            catch (Exception) {
                //not found
            }

            if (partner != null)
            {
                //notify other partners
                partnership.getAllPartners()
                .Where(x => x.ProfileID != profileID && x.ProfileID != currentProfile.ProfileID)
                .ToList()
                .ForEach(x => {
                    //notifications
                    var notification = new Notification {
                        Account      = x.getAccount(),
                        Category     = "Partnership Update",
                        Message      = profile.Organization.Name + " is no longer a partner of the \"" + partnership.Name + "\" partnership",
                        LinkToAction = Url.Action("Detail", new { partnershipID })
                    };
                    _workUnit.NotificationRepository.InsertEntity(notification);
                });
                //notify the removed partner
                var n = new Notification {
                    Account  = profile.getAccount(),
                    Category = "Partnership Update",
                    Message  = "You are no longer a partner of the \"" + partnership.Name + "\" partnership",
                    Message2 = "The administrator has removed you emailAddress the partnership.",
                    Message3 = "There is no further action neccessary. You can request to join other partnerships."
                };
                _workUnit.NotificationRepository.InsertEntity(n);
                _workUnit.saveChanges();
                updateTempMessage(profile.Organization.Name + " has been removed emailAddress \"" + partnership.Name + "\" partnership");
            }
            else
            {
                updateTempMessage("Error removing partner emailAddress partnership.");
            }

            return(returnToUrl(returnUrl, Url.Action("Detail", new { partnershipID })));
        }
Exemple #2
0
        public ActionResult Create(Partnership partnership)
        {
            if (ModelState.IsValid)
            {
                var partnershipDetail = new PartnershipDetail()
                {
                    Profile     = CurrentAccount.Profile,
                    Type        = "Owner",
                    Partnership = partnership
                };
                _workUnit.PartnershipDetailRepository.InsertEntity(partnershipDetail);
                _workUnit.saveChanges();
                //notifications
                var notification = new Notification {
                    Account      = CurrentAccount,
                    Category     = "New Partnership Profile Created",
                    Header       = "Thank you for creating a Partnership Profile on EARN MD CONNECT!",
                    Message      = @"You are now the Administrator of your Partnership Profile. 
As the Administrator, you are the only user able 1) to control the Partnership Profile’s membership, 2) 
to invite other organizations to join your Partnership Profile, and 3) 
to decide whether to approve users who request to join your Partnership Profile.

If you are the appropriate Administrator for your partnership’s EARN MD CONNECT Partnership Profile, you’re ready to get started!
You may also designate additional Administrators of your Partnership Profile. To do so, click on the “Partners” tab on the bottom 
left of your Partnership Profile detail page. Select the desired Partner Organization, and click the “Make Admin” button to assign 
Administrator Privileges. You may also remove your organization as an Administrator if there exists one or more other Administrators. 
To do so, simply click the “Remove Admin” button next to your own Organization’s profile within the “Partners” tab of your Partnership Profile page.
",
                    Message2     = @"Next, please visit your EARN MD CONNECT Partnership Profile and invite 
your partners to join the Partnership Profile on EARN MD CONNECT, communicate with your partners, 
and search for any other Partnership Profiles that may be of interest to you.",
                    Message3     = @"Please note: 1) to become a member of an EARN MD CONNECT Partnership Profile, 
a user must first have, or create an Organizational Profile; 2) the Partnership Profile’s Title, 
Description, Target Industry, region, and membership will be visible to other EARN MD CONNECT users; 3) 
full Partnership Profiles, including the communication function, are only accessible to that Partnership 
Profile’s members, and 4) the communication feature is meant to support communication between partners, 
but should not be used to share proprietary or sensitive content.",
                    LinkToAction = Url.Action("Detail", new { partnership.PartnershipID })
                };
                _workUnit.NotificationRepository.InsertEntity(notification);
                _workUnit.saveChanges();
                return(RedirectToAction("Detail", new { partnership.PartnershipID }));
            }
            //error
            return(View(partnership));
        }
Exemple #3
0
        public ActionResult LeavePartnershipPost(int partnershipID, string returnUrl)
        {
            var partnership           = _workUnit.PartnershipRepository.GetEntityByID(partnershipID);
            var currentProfile        = CurrentAccount.Profile;
            PartnershipDetail partner = null;

            try {
                partner = _workUnit.PartnershipDetailRepository.Entities
                          .First(x => x.ProfileID == currentProfile.ProfileID && x.PartnershipID == partnershipID);
                _workUnit.PartnershipDetailRepository.DeleteByID(partner.PartnershipDetailID);
            }
            catch (Exception) {
                //not found
            }

            if (partner != null)
            {
                //notify other partners
                partnership.getAllPartners()
                .Where(x => x.ProfileID != currentProfile.ProfileID)
                .ToList()
                .ForEach(x => {
                    x.Accounts.ToList().ForEach(a => {
                        //notifications
                        var notification = new Notification {
                            Account      = a,
                            Category     = "Partnership Update",
                            Message      = currentProfile.Organization.Name + " has left the \"" + partnership.Name + "\" partnership.",
                            LinkToAction = Url.Action("Detail", new { partnershipID })
                        };
                        _workUnit.NotificationRepository.InsertEntity(notification);
                    });
                });

                _workUnit.saveChanges();
                updateTempMessage("You have left the \"" + partnership.Name + "\" partnership");
                return(RedirectToAction("MyPartnerships"));
            }
            else
            {
                updateTempMessage("Error leaving partnership.");
            }

            return(returnToUrl(returnUrl, Url.Action("Detail", new { partnershipID })));
        }
        public ActionResult AcceptRequest(int requestID)
        {
            var request                     = _workUnit.RequestRepository.GetEntityByID(requestID);
            PartnershipRequest r            = null;
            Notification       notification = null;
            PartnershipDetail  detail       = null;

            switch (request.Type.ToLower())
            {
            case "partnership request":
                r = (PartnershipRequest)request;
                if (r.Partnership != null)
                {
                    //check if the requested organization is already a partner
                    if (r.Partnership.getPartners().Contains(r.Sender))
                    {
                        updateTempMessage("\"" + r.Sender.Organization.Name
                                          + "\"is already a partner of this partnership");
                        _workUnit.RequestRepository.DeleteByID(requestID);
                        break;
                    }
                    //form a partner reference
                    detail = new PartnershipDetail()
                    {
                        Partnership = r.Partnership,
                        Profile     = r.Sender,
                        Type        = "partner"
                    };
                    var message = string.Format(@"You have accepted {0} to join the ""{1}"" partnership.",
                                                r.Sender.Organization.Name,
                                                r.Partnership.Name);
                    updateTempMessage(message);
                    r.Sender.Accounts.ToList().ForEach(x => {
                        //create notification to sender
                        notification = new Notification()
                        {
                            Account  = x,
                            Category = "Partnership Request Accepted",
                            Message  = string.Format(@"{0} has accepted your request. You are now a partner of ""{1}""",
                                                     r.Receiver.Organization.Name,
                                                     r.Partnership.Name),
                            Message2 = "You can now visit the \"" + r.Partnership.Name
                                       + "\" partnership’s partnership, and communicate with your partners!",
                            LinkToAction = Url.Action("Detail", "Partnership", new { r.PartnershipID })
                        };
                        _workUnit.NotificationRepository.InsertEntity(notification);
                    });
                }
                break;

            case "partnership invite":
                r = (PartnershipRequest)request;
                if (r.Partnership != null)
                {
                    //check if the invited organization is already a partner
                    if (r.Partnership.getPartners().Contains(r.Receiver))
                    {
                        updateTempMessage("You are already a partner of this partnership");
                        break;
                    }
                    //form a partner reference
                    detail = new PartnershipDetail()
                    {
                        Partnership = r.Partnership,
                        Profile     = r.Receiver,
                        Type        = "partner"
                    };
                    _workUnit.PartnershipDetailRepository.InsertEntity(detail);
                    var message = "You are now a partner of the \"" + r.Partnership.Name + "\" partnership.";
                    updateTempMessage(message);
                    r.Sender.Accounts.ToList().ForEach(x => {
                        //create notification
                        notification = new Notification()
                        {
                            Account  = x,
                            Category = "Partnership Invite Accepted",
                            Message  = string.Format(@"{0} is now a new partner of your ""{1}"" partnership",
                                                     r.Receiver.Organization.Name,
                                                     r.Partnership.Name),
                            LinkToAction = Url.Action("Detail", "Partnership", new { r.PartnershipID })
                        };
                        _workUnit.NotificationRepository.InsertEntity(notification);
                    });
                }
                break;
            }

            if (detail != null)
            {
                _workUnit.PartnershipDetailRepository.InsertEntity(detail);
                _workUnit.RequestRepository.DeleteByID(requestID);
            }
            _workUnit.saveChanges();

            return(RedirectToAction("Requests"));
        }