Beispiel #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_JG_1711 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var community = ORM_HEC_CMT_Community.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                IsCommunityOperatedByThisTenant = true
            }).Single();

            var m2g = new ORM_HEC_CMT_GroupSubscription()
            {
                Tenant_RefID                = securityTicket.TenantID,
                Membership_RefID            = Parameter.HEC_CMT_MembershipID,
                CommunityGroup_RefID        = Parameter.HEC_CMT_CommunityGroupID,
                HEC_CMT_GroupSubscriptionID = Guid.NewGuid()
            };
            m2g.Save(Connection, Transaction);

            var query = new ORM_HEC_CMT_OfferedRole.Query();
            query.GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingID;
            query.IsDeleted    = false;
            query.Tenant_RefID = securityTicket.TenantID;

            var role = ORM_HEC_CMT_OfferedRole.Query.Search(Connection, Transaction, query).Single();

            var r2gs = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription()
            {
                Tenant_RefID = securityTicket.TenantID,
                AssignmentID = Guid.NewGuid(),
                HEC_CMT_GroupSubscription_RefID = m2g.HEC_CMT_GroupSubscriptionID,
                HEC_CMT_OfferedRole_RefID       = role.HEC_CMT_OfferedRoleID
            };
            r2gs.Save(Connection, Transaction);

            return(returnValue);

            #endregion UserCode
        }
Beispiel #2
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_AR_1111 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();

            var roles = ORM_HEC_CMT_OfferedRole.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRole.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false
            }).ToArray();

            var roleToId = new Dictionary <ECommunityRole, ORM_HEC_CMT_OfferedRole>();
            foreach (var role in roles)
            {
                roleToId.Add(EnumUtils.GetEnumValueByDescription <ECommunityRole>(role.GlobalPropertyMatchingID), role);
            }


            var request = ORM_HEC_CMT_GroupSubscription_Request.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription_Request.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                HEC_CMT_GroupSubscription_RequestID = Parameter.HEC_CMT_GroupSubscription_RequestID
            }).Single();

            var roleRequest = ORM_HEC_CMT_OfferedRoles_2_GroupSubscriptionRequest.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRoles_2_GroupSubscriptionRequest.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                HEC_CMT_GroupSubscription_Request_RefID = request.HEC_CMT_GroupSubscription_RequestID
            }).Single();

            var groupSubscription = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query()
            {
                Tenant_RefID         = securityTicket.TenantID,
                Membership_RefID     = request.Membership_RefID,
                CommunityGroup_RefID = request.CommunityGroup_RefID,
                IsDeleted            = false
            }).SingleOrDefault();

            if (groupSubscription == null)
            {
                groupSubscription = new ORM_HEC_CMT_GroupSubscription()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    HEC_CMT_GroupSubscriptionID = Guid.NewGuid(),
                    Membership_RefID            = request.Membership_RefID,
                    CommunityGroup_RefID        = request.CommunityGroup_RefID
                };
                groupSubscription.Save(Connection, Transaction);
            }

            var r2gs = ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                HEC_CMT_GroupSubscription_RefID = groupSubscription.HEC_CMT_GroupSubscriptionID,
                IsDeleted = false
            }).ToArray();

            var selectedRole = roleToId.ToArray().Single(s => s.Value.HEC_CMT_OfferedRoleID == roleRequest.HEC_CMT_OfferedRole_RefID).Key;

            if (selectedRole == ECommunityRole.Consumer)
            {
                var consumerRole = roleToId[ECommunityRole.Consumer];

                var groupSubscriptions = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query()
                {
                    Tenant_RefID     = securityTicket.TenantID,
                    Membership_RefID = request.Membership_RefID,
                    IsDeleted        = false
                }).ToArray();

                foreach (var gs in groupSubscriptions)
                {
                    if (groupSubscription.HEC_CMT_GroupSubscriptionID != gs.HEC_CMT_GroupSubscriptionID)
                    {
                        var number = ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query.SoftDelete(Connection, Transaction, new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription.Query()
                        {
                            Tenant_RefID = securityTicket.TenantID,
                            HEC_CMT_GroupSubscription_RefID = gs.HEC_CMT_GroupSubscriptionID,
                            HEC_CMT_OfferedRole_RefID       = consumerRole.HEC_CMT_OfferedRoleID,
                            IsDeleted = false
                        });
                    }
                }
            }
            else if (selectedRole >= ECommunityRole.Administrator)
            {
                foreach (var r2g in r2gs)
                {
                    var currentRole = roleToId.ToArray().Single(s => s.Value.HEC_CMT_OfferedRoleID == r2g.HEC_CMT_OfferedRole_RefID).Key;
                    if (currentRole >= ECommunityRole.Administrator)
                    {
                        r2g.IsDeleted = true;
                        r2g.Save(Connection, Transaction);
                    }
                }
            }

            var roleSbs = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription()
            {
                Tenant_RefID = securityTicket.TenantID,
                AssignmentID = Guid.NewGuid(),
                HEC_CMT_GroupSubscription_RefID = groupSubscription.HEC_CMT_GroupSubscriptionID,
                HEC_CMT_OfferedRole_RefID       = roleRequest.HEC_CMT_OfferedRole_RefID
            };
            roleSbs.Save(Connection, Transaction);


            request.IfApproved_GroupSubscription_RefID = groupSubscription.HEC_CMT_GroupSubscriptionID;
            request.IsApproved = true;
            request.IfApproved_ByMember_RefID = Parameter.By_HEC_CMT_MembershipID;
            request.Save(Connection, Transaction);

            return(returnValue);

            #endregion UserCode
        }
Beispiel #3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_SG_1701 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var community = ORM_HEC_CMT_Community.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                IsCommunityOperatedByThisTenant = true
            }).Single();

            if (Parameter.HEC_CMT_CommunityGroupID == Guid.Empty)
            {
                Random _rng         = new Random((int)DateTime.Now.Ticks);
                string _chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
                int    loopCountMax = 100;
                int    loopCounter  = 0;
                bool   uniqueFlag   = false;
                string codeValue;

                do
                {
                    loopCounter++;
                    if (loopCounter > loopCountMax)
                    {
                        return(null);
                    }

                    char[] buffer = new char[6];
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        buffer[i] = _chars[_rng.Next(_chars.Length)];
                    }
                    codeValue = new string(buffer);

                    var query1 = new ORM_HEC_CMT_CommunityGroup.Query();
                    query1.CommunityGroupCode = codeValue;
                    query1.Tenant_RefID       = securityTicket.TenantID;
                    query1.IsDeleted          = false;

                    var codes = ORM_HEC_CMT_CommunityGroup.Query.Search(Connection, Transaction, query1);
                    if (codes.Count == 0)
                    {
                        uniqueFlag = true;
                    }
                } while (!uniqueFlag);

                var group = new ORM_HEC_CMT_CommunityGroup()
                {
                    Tenant_RefID                = securityTicket.TenantID,
                    IsPrivate                   = Parameter.IsPrivate,
                    IsDeleted                   = false,
                    CommunityGroupCode          = codeValue,
                    CommunityGroup_Name         = Parameter.GroupName,
                    CommunityGroup_Description  = Parameter.GroupDescription,
                    HealthcareCommunityGroupITL = Guid.NewGuid().ToString(),
                    HEC_CMT_CommunityGroupID    = Guid.NewGuid(),
                    Community_RefID             = community.HEC_CMT_CommunityID
                };
                group.Save(Connection, Transaction);

                var member = ORM_HEC_CMT_Membership.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Membership.Query()
                {
                    IsDeleted                 = false,
                    Tenant_RefID              = securityTicket.TenantID,
                    Community_RefID           = community.HEC_CMT_CommunityID,
                    BusinessParticipant_RefID = Parameter.UserBPID
                }).Single();

                var m2g = new ORM_HEC_CMT_GroupSubscription()
                {
                    Tenant_RefID         = securityTicket.TenantID,
                    Membership_RefID     = member.HEC_CMT_MembershipID,
                    CommunityGroup_RefID = group.HEC_CMT_CommunityGroupID
                };
                m2g.Save(Connection, Transaction);

                var founderRoleID = DMCommunityRoles.Get_CommunityRole_for_GlobalPropertyMatchingID(Connection, Transaction,
                                                                                                    EnumUtils.GetEnumDescription(ECommunityRole.Founder_Init), community.HEC_CMT_CommunityID, securityTicket);

                var contributorRoleID = DMCommunityRoles.Get_CommunityRole_for_GlobalPropertyMatchingID(Connection, Transaction,
                                                                                                        EnumUtils.GetEnumDescription(ECommunityRole.Contributor), community.HEC_CMT_CommunityID, securityTicket);

                DMCommunityRoles.Get_CommunityRole_for_GlobalPropertyMatchingID(Connection, Transaction,
                                                                                EnumUtils.GetEnumDescription(ECommunityRole.Bureaucrat), community.HEC_CMT_CommunityID, securityTicket);
                DMCommunityRoles.Get_CommunityRole_for_GlobalPropertyMatchingID(Connection, Transaction,
                                                                                EnumUtils.GetEnumDescription(ECommunityRole.Founder), community.HEC_CMT_CommunityID, securityTicket);

                var r2gFounder = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    AssignmentID = Guid.NewGuid(),
                    HEC_CMT_GroupSubscription_RefID = m2g.HEC_CMT_GroupSubscriptionID,
                    HEC_CMT_OfferedRole_RefID       = founderRoleID
                };
                r2gFounder.Save(Connection, Transaction);

                var r2gContributor = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription()
                {
                    Tenant_RefID = securityTicket.TenantID,
                    AssignmentID = Guid.NewGuid(),
                    HEC_CMT_GroupSubscription_RefID = m2g.HEC_CMT_GroupSubscriptionID,
                    HEC_CMT_OfferedRole_RefID       = contributorRoleID
                };
                r2gContributor.Save(Connection, Transaction);

                returnValue.Result = group.HEC_CMT_CommunityGroupID;
            }
            else
            {
                var group = ORM_HEC_CMT_CommunityGroup.Query.Search(Connection, Transaction, new ORM_HEC_CMT_CommunityGroup.Query()
                {
                    IsDeleted                = false,
                    Tenant_RefID             = securityTicket.TenantID,
                    HEC_CMT_CommunityGroupID = Parameter.HEC_CMT_CommunityGroupID
                }).Single();

                group.IsPrivate                  = Parameter.IsPrivate;
                group.CommunityGroup_Name        = Parameter.GroupName;
                group.CommunityGroup_Description = Parameter.GroupDescription;
                group.Save(Connection, Transaction);

                returnValue.Result = Parameter.HEC_CMT_CommunityGroupID;
            }

            return(returnValue);

            #endregion UserCode
        }
Beispiel #4
0
        protected static FR_L5MC_JPG_1356 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MC_JPG_1356 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5MC_JPG_1356();
            returnValue.Result = new L5MC_JPG_1356();

            var group = ORM_HEC_CMT_CommunityGroup.Query.Search(Connection, Transaction, new ORM_HEC_CMT_CommunityGroup.Query()
            {
                IsDeleted          = false,
                Tenant_RefID       = securityTicket.TenantID,
                IsPrivate          = true,
                CommunityGroupCode = Parameter.GroupCode
            }).SingleOrDefault();

            if (group != null)
            {
                returnValue.Result.Group = new L5MC_JPG_1356_Group()
                {
                    HEC_CMT_CommunityGroupID = group.HEC_CMT_CommunityGroupID
                };

                var posibleCurrentAssignment = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query()
                {
                    Tenant_RefID         = securityTicket.TenantID,
                    IsDeleted            = false,
                    Membership_RefID     = Parameter.HEC_CMT_MembershipID,
                    CommunityGroup_RefID = group.HEC_CMT_CommunityGroupID
                }).ToArray();

                if (posibleCurrentAssignment.Length == 0)
                {
                    var community = ORM_HEC_CMT_Community.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community.Query()
                    {
                        Tenant_RefID = securityTicket.TenantID,
                        IsDeleted    = false,
                        IsCommunityOperatedByThisTenant = true
                    }).Single();

                    var m2g = new ORM_HEC_CMT_GroupSubscription()
                    {
                        Tenant_RefID                = securityTicket.TenantID,
                        Membership_RefID            = Parameter.HEC_CMT_MembershipID,
                        CommunityGroup_RefID        = group.HEC_CMT_CommunityGroupID,
                        HEC_CMT_GroupSubscriptionID = Guid.NewGuid()
                    };
                    m2g.Save(Connection, Transaction);

                    var query = new ORM_HEC_CMT_OfferedRole.Query();
                    query.GlobalPropertyMatchingID = Parameter.GlobalPropertyMatchingID;
                    query.IsDeleted    = false;
                    query.Tenant_RefID = securityTicket.TenantID;

                    var role = ORM_HEC_CMT_OfferedRole.Query.Search(Connection, Transaction, query).Single();

                    var r2gs = new ORM_HEC_CMT_OfferedRoles_2_GroupSubscription()
                    {
                        Tenant_RefID = securityTicket.TenantID,
                        AssignmentID = Guid.NewGuid(),
                        HEC_CMT_GroupSubscription_RefID = m2g.HEC_CMT_GroupSubscriptionID,
                        HEC_CMT_OfferedRole_RefID       = role.HEC_CMT_OfferedRoleID
                    };
                    r2gs.Save(Connection, Transaction);

                    returnValue.Result.Group.Success = true;
                }
            }

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5MPC_SMC_1101 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            returnValue.Result = new Guid();
            #region Save

            var community = ORM_HEC_CMT_Community.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                IsCommunityOperatedByThisTenant = true
            }).Single();

            var membershipType = ORM_HEC_CMT_Community_OfferedMembershipType.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Community_OfferedMembershipType.Query()
            {
                Tenant_RefID           = securityTicket.TenantID,
                IsDeleted              = false,
                IsAvailableFor_Tenants = Parameter.IsTenant,
                IsAvailableFor_Doctors = !Parameter.IsTenant
            }).Single();

            var members = ORM_HEC_CMT_Membership.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Membership.Query()
            {
                Tenant_RefID = securityTicket.TenantID,
                IsDeleted    = false,
                BusinessParticipant_RefID = Parameter.BusinessParticipantID
            }).SingleOrDefault();
            if (members == null)
            {
                members = new ORM_HEC_CMT_Membership()
                {
                    HEC_CMT_MembershipID      = Guid.NewGuid(),
                    Tenant_RefID              = securityTicket.TenantID,
                    CommunityMembershipITL    = Guid.Empty.ToString(),
                    BusinessParticipant_RefID = Parameter.BusinessParticipantID,
                    Community_RefID           = community.HEC_CMT_CommunityID
                };
                members.Save(Connection, Transaction);
            }

            var creds = ORM_HEC_CMT_Membership_Credential.Query.Search(Connection, Transaction, new ORM_HEC_CMT_Membership_Credential.Query()
            {
                Tenant_RefID     = securityTicket.TenantID,
                IsDeleted        = false,
                Membership_RefID = members.HEC_CMT_MembershipID
            }).SingleOrDefault();
            if (creds == null)
            {
                creds = new ORM_HEC_CMT_Membership_Credential()
                {
                    HEC_CMT_Membership_CredentialID = Guid.NewGuid(),
                    Tenant_RefID     = securityTicket.TenantID,
                    Membership_RefID = members.HEC_CMT_MembershipID,
                };
            }
            creds.Membership_Password = Parameter.Membership_Password;
            creds.Membership_Username = Parameter.Membership_Username;
            creds.Save(Connection, Transaction);

            if (!Parameter.IsTenant)
            {
                var group = ORM_HEC_CMT_CommunityGroup.Query.Search(Connection, Transaction, new ORM_HEC_CMT_CommunityGroup.Query()
                {
                    Tenant_RefID       = securityTicket.TenantID,
                    IsPrivate          = false,
                    IsDeleted          = false,
                    CommunityGroupCode = "FAVORITES"
                }).Single();

                var m2g = ORM_HEC_CMT_GroupSubscription.Query.Search(Connection, Transaction, new ORM_HEC_CMT_GroupSubscription.Query()
                {
                    Tenant_RefID         = securityTicket.TenantID,
                    IsDeleted            = false,
                    Membership_RefID     = members.HEC_CMT_MembershipID,
                    CommunityGroup_RefID = group.HEC_CMT_CommunityGroupID
                }).SingleOrDefault();
                if (m2g == null)
                {
                    m2g = new ORM_HEC_CMT_GroupSubscription()
                    {
                        Tenant_RefID         = securityTicket.TenantID,
                        Membership_RefID     = members.HEC_CMT_MembershipID,
                        CommunityGroup_RefID = group.HEC_CMT_CommunityGroupID
                    };
                    m2g.Save(Connection, Transaction);
                }
            }


            #endregion

            return(returnValue);

            #endregion UserCode
        }