Пример #1
0
 public IHttpActionResult VadifyGroupMemeber(string MemberId, string Code, string UserId)
 {
     Domain.Socioboard.Domain.Groupmembers grpMember = groupMembersRepository.GetGroupMember(Guid.Parse(MemberId));
     Domain.Socioboard.Domain.User         user      = userrepo.getUsersById(Guid.Parse(UserId));
     if (grpMember == null)
     {
         return(Ok("Member Not Exist"));
     }
     if (grpMember != null && user.EmailId == grpMember.Emailid)
     {
         if (grpMember.Membercode.Equals(Code))
         {
             grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
             grpMember.Userid = user.Id.ToString();
             groupMembersRepository.updateBoard(grpMember);
             return(Ok("added"));
         }
         else
         {
             return(Ok("Wrong Code"));
         }
     }
     else
     {
         return(Ok("Email Doesn't match"));
     }
 }
        public bool updateBoard(Domain.Socioboard.Domain.Groupmembers grpMember)
        {
            bool isUpdate = false;

            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        // Proceed action to Update Data.
                        // And Set the reuired paremeters to find the specific values.
                        session.CreateQuery("Update Groupmembers set Emailid=:Emailid,Groupid=:Groupid,IsAdmin=:IsAdmin,Membercode=:Membercode,Status=:Status,Userid=:Userid where Id = :Id")
                        .SetParameter("Emailid", grpMember.Emailid)
                        .SetParameter("Groupid", grpMember.Groupid)
                        .SetParameter("IsAdmin", grpMember.IsAdmin)
                        .SetParameter("Membercode", grpMember.Membercode)
                        .SetParameter("Status", grpMember.Status)
                        .SetParameter("Userid", grpMember.Userid)
                        .SetParameter("Id", grpMember.Id)
                        .ExecuteUpdate();
                        transaction.Commit();
                        isUpdate = true;
                        return(isUpdate);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(isUpdate);
                    }
                } //End Transaction
            }     //End session
        }
 /// <AddGroup>
 /// Add a new group
 /// </summary>
 /// <param name="group">Set Values in a Groups Class Property and Pass the same Object of Groups Class.(Domain.Groups)</param>
 public void AddGroupMemeber(Domain.Socioboard.Domain.Groupmembers groupMember)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to save data.
             session.Save(groupMember);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
 public Domain.Socioboard.Domain.Groupmembers GetGroupMember(Guid Id)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             // proceed action, to get all Facebook Account of User by UserId(Guid) and FbUserId(string).
             NHibernate.IQuery query = session.CreateQuery("from Groupmembers where Id = :Id");
             query.SetParameter("Id", Id);
             Domain.Socioboard.Domain.Groupmembers result = (Domain.Socioboard.Domain.Groupmembers)query.UniqueResult();
             return(result);
         } //End Transaction
     }     //End session
 }
Пример #5
0
        public bool GrpMem(Domain.Socioboard.Domain.User user)
        {
            GroupsRepository       grpRep    = new GroupsRepository();
            GroupMembersRepository grpMemRep = new GroupMembersRepository();
            UserRepository         userRepo  = new UserRepository();

            // Domain.Socioboard.Domain.User user = userRepo.getUserInfoByEmail(Email);
            //foreach (var user in lstUser)
            //{
            try
            {
                List <Domain.Socioboard.Domain.Groups> lstGroups = grpRep.getAlluserGroups(user.Id);
                foreach (var item in lstGroups)
                {
                    try
                    {
                        if (user != null)
                        {
                            Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers();
                            grpMember.Id      = Guid.NewGuid();
                            grpMember.Emailid = user.EmailId;
                            grpMember.Groupid = item.Id.ToString();
                            grpMember.IsAdmin = true;
                            grpMember.Status  = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
                            grpMember.Userid  = item.UserId.ToString();
                            if (!grpMemRep.checkMemberExistsingroup(grpMember.Groupid, grpMember.Userid))
                            {
                                grpMemRep.AddGroupMemeber(grpMember);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                    }
                }
            }
            catch (Exception e) { }


            //}

            return(true);
        }
        public bool GrpMem(Domain.Socioboard.Domain.User user) 
        {
            GroupsRepository grpRep = new GroupsRepository();
            GroupMembersRepository grpMemRep = new GroupMembersRepository();
            UserRepository userRepo = new UserRepository();
           // Domain.Socioboard.Domain.User user = userRepo.getUserInfoByEmail(Email);
            //foreach (var user in lstUser) 
            //{
                try 
                {
                    List<Domain.Socioboard.Domain.Groups> lstGroups = grpRep.getAlluserGroups(user.Id);
                    foreach (var item in lstGroups)
                    {
                        try
                        {
                            if (user != null)
                            {
                                Domain.Socioboard.Domain.Groupmembers grpMember = new Domain.Socioboard.Domain.Groupmembers();
                                grpMember.Id = Guid.NewGuid();
                                grpMember.Emailid = user.EmailId;
                                grpMember.Groupid = item.Id.ToString();
                                grpMember.IsAdmin = true;
                                grpMember.Status = Domain.Socioboard.Domain.GroupUserStatus.Accepted;
                                grpMember.Userid = item.UserId.ToString();
                                if (!grpMemRep.checkMemberExistsingroup(grpMember.Groupid, grpMember.Userid))
                                {
                                    grpMemRep.AddGroupMemeber(grpMember);
                                }

                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            logger.Error(ex.StackTrace);
                        }


                    }
                }
                catch (Exception e) { }
               

            //}
            
            return true;

        }
        public IHttpActionResult AddGroupMembers(string Emails, string GroupId, string UserId)
        {
            Domain.Socioboard.Domain.Groups group = groupRepo.getGroupDetailsbyId(Guid.Parse(UserId), Guid.Parse(GroupId));
            string ret = string.Empty;
            string SentMails = string.Empty;
            try
            {
                List<string> arr = new List<string>();
                string[] arr1 = new string[] { };
                string NotSentMails = string.Empty;
                string selectedgroupid = string.Empty;

                if (Emails.Contains(','))
                {
                    arr = Emails.Split(',').ToList();
                }
                else
                {
                    //arr[0] = email;
                    arr.Add(Emails);
                }

                foreach (var item in arr)
                {
                    if (item.Contains(':'))
                    {
                        arr1 = item.Split(':');
                    }

                    //string res = "";
                    Domain.Socioboard.Domain.User objuserinfo = userrepo.getUserInfoByEmail(arr1[0]);

                    if (objuserinfo != null)
                    {
                        string[] name = objuserinfo.UserName.Split(' ');
                        string fname = name[0];
                        string lname = string.Empty;
                        for (int i = 1; i < name.Length; i++)
                        {
                            lname += name[i];
                        }

                        // res = ApiobjTeam.AddTeam(objuserinfo.Id.ToString(), "0", fname, lname, arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                        Domain.Socioboard.Domain.Groupmembers groupMemeber = new Domain.Socioboard.Domain.Groupmembers();
                        groupMemeber.Id = Guid.NewGuid();
                        groupMemeber.Emailid = objuserinfo.EmailId;
                        groupMemeber.Groupid = GroupId;
                        groupMemeber.Status = Domain.Socioboard.Domain.GroupUserStatus.Pending;
                        groupMemeber.Userid = objuserinfo.Id.ToString();
                        groupMemeber.Membercode = Api.Socioboard.Helper.Utility.GenerateRandomUniqueString();
                        groupMembersRepository.AddGroupMemeber(groupMemeber);

                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                        string html = File.ReadAllText(mailpath);
                        html = html.Replace("[group_name]", group.GroupName);
                        html = html.Replace("[join link]", "Home/GroupMember?MemberId=" + groupMemeber.Id + "&code=" + groupMemeber.Membercode);
                        MailSender objMailSender = new MailSender();
                        ret = objMailSender.SendChangePasswordMail(objuserinfo.EmailId, html, "Group Invitation");
                    }
                    else
                    {
                        //res = ApiobjTeam.AddTeam(objUser.Id.ToString(), "0", arr1[1], arr1[2], arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                        Domain.Socioboard.Domain.Groupmembers groupMemeber = new Domain.Socioboard.Domain.Groupmembers();
                        groupMemeber.Id = Guid.NewGuid();
                        groupMemeber.Emailid = arr1[0];
                        groupMemeber.Groupid = GroupId;
                        groupMemeber.Status = Domain.Socioboard.Domain.GroupUserStatus.Pending;
                        groupMemeber.Membercode = Api.Socioboard.Helper.Utility.GenerateRandomUniqueString();
                        // groupMemeber.Userid = objuserinfo.Id.ToString();
                        groupMembersRepository.AddGroupMemeber(groupMemeber);


                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                        string html = File.ReadAllText(mailpath);
                        html = html.Replace("[group_name]", group.GroupName);
                        html = html.Replace("[join link]", "Home/GroupMember?MemberId=" + groupMemeber.Id + "&code=" + groupMemeber.Membercode);
                        MailSender objMailSender = new MailSender();
                        ret = objMailSender.SendChangePasswordMail(arr1[0], html, "Group Invitation");
                    }
                }
                SentMails = "{\"SentMails\":" + "\"" + SentMails + "\",\"NotSentMails\":" + "\"" + NotSentMails + "\"}";
                return Ok(SentMails);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return BadRequest();
            }

        }
Пример #8
0
        public IHttpActionResult AddGroupMembers(string Emails, string GroupId, string UserId)
        {
            Domain.Socioboard.Domain.Groups group = groupRepo.getGroupDetailsbyId(Guid.Parse(UserId), Guid.Parse(GroupId));
            string ret       = string.Empty;
            string SentMails = string.Empty;

            try
            {
                List <string> arr             = new List <string>();
                string[]      arr1            = new string[] { };
                string        NotSentMails    = string.Empty;
                string        selectedgroupid = string.Empty;

                if (Emails.Contains(','))
                {
                    arr = Emails.Split(',').ToList();
                }
                else
                {
                    //arr[0] = email;
                    arr.Add(Emails);
                }

                foreach (var item in arr)
                {
                    if (item.Contains(':'))
                    {
                        arr1 = item.Split(':');
                    }

                    //string res = "";
                    Domain.Socioboard.Domain.User objuserinfo = userrepo.getUserInfoByEmail(arr1[0]);

                    if (objuserinfo != null)
                    {
                        string[] name  = objuserinfo.UserName.Split(' ');
                        string   fname = name[0];
                        string   lname = string.Empty;
                        for (int i = 1; i < name.Length; i++)
                        {
                            lname += name[i];
                        }

                        // res = ApiobjTeam.AddTeam(objuserinfo.Id.ToString(), "0", fname, lname, arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                        Domain.Socioboard.Domain.Groupmembers groupMemeber = new Domain.Socioboard.Domain.Groupmembers();
                        groupMemeber.Id         = Guid.NewGuid();
                        groupMemeber.Emailid    = objuserinfo.EmailId;
                        groupMemeber.Groupid    = GroupId;
                        groupMemeber.Status     = Domain.Socioboard.Domain.GroupUserStatus.Pending;
                        groupMemeber.Userid     = objuserinfo.Id.ToString();
                        groupMemeber.Membercode = Api.Socioboard.Helper.Utility.GenerateRandomUniqueString();
                        groupMembersRepository.AddGroupMemeber(groupMemeber);

                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                        string html     = File.ReadAllText(mailpath);
                        html = html.Replace("[group_name]", group.GroupName);
                        html = html.Replace("[join link]", "Home/GroupMember?MemberId=" + groupMemeber.Id + "&code=" + groupMemeber.Membercode);
                        MailSender objMailSender = new MailSender();
                        ret = objMailSender.SendChangePasswordMail(objuserinfo.EmailId, html, "Group Invitation");
                    }
                    else
                    {
                        //res = ApiobjTeam.AddTeam(objUser.Id.ToString(), "0", arr1[1], arr1[2], arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                        Domain.Socioboard.Domain.Groupmembers groupMemeber = new Domain.Socioboard.Domain.Groupmembers();
                        groupMemeber.Id         = Guid.NewGuid();
                        groupMemeber.Emailid    = arr1[0];
                        groupMemeber.Groupid    = GroupId;
                        groupMemeber.Status     = Domain.Socioboard.Domain.GroupUserStatus.Pending;
                        groupMemeber.Membercode = Api.Socioboard.Helper.Utility.GenerateRandomUniqueString();
                        // groupMemeber.Userid = objuserinfo.Id.ToString();
                        groupMembersRepository.AddGroupMemeber(groupMemeber);


                        string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                        string html     = File.ReadAllText(mailpath);
                        html = html.Replace("[group_name]", group.GroupName);
                        html = html.Replace("[join link]", "Home/GroupMember?MemberId=" + groupMemeber.Id + "&code=" + groupMemeber.Membercode);
                        MailSender objMailSender = new MailSender();
                        ret = objMailSender.SendChangePasswordMail(arr1[0], html, "Group Invitation");
                    }
                }
                SentMails = "{\"SentMails\":" + "\"" + SentMails + "\",\"NotSentMails\":" + "\"" + NotSentMails + "\"}";
                return(Ok(SentMails));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return(BadRequest());
            }
        }