示例#1
0
        public string AddTeam(string UserId, string InviteStatus, string FirstName, string LastName, string EmailId, string AccessLevel, string GroupId, string useremail, string username)
        {
            try
            {
                if (!teamrepo.checkTeamExists(EmailId, Guid.Parse(UserId), Guid.Parse(GroupId)))
                {
                    Domain.Socioboard.Domain.Groups _Groups = objGroupsRepository.getGroupDetailsbyId(Guid.Parse(UserId), Guid.Parse(GroupId));
                    team.Id = Guid.NewGuid();
                    team.UserId = Guid.Parse(UserId);
                    team.InviteStatus = Convert.ToInt32(InviteStatus);
                    team.InviteDate = DateTime.Now;
                    team.StatusUpdateDate = DateTime.Now;
                    team.GroupId = Guid.Parse(GroupId);
                    team.StatusUpdateDate = DateTime.Now;
                    team.FirstName = FirstName;
                    team.LastName = LastName;
                    team.EmailId = EmailId;
                    team.AccessLevel = AccessLevel;
                    teamrepo.addNewTeam(team);
                    string check = team.Id.ToString();

                    string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                    string html = File.ReadAllText(mailpath);
                    html = html.Replace("[group_name]",_Groups.GroupName);
                    html = html.Replace("[join link]", "Home/Index?teamid=" + team.Id.ToString());
                    //string usernameSend = ConfigurationManager.AppSettings["Mandrillusername"];
                    //string host = ConfigurationManager.AppSettings["Mandrillhost"];
                    //string port = ConfigurationManager.AppSettings["Mandrillport"];
                    //string pass = ConfigurationManager.AppSettings["Mandrillpassword"];
                    //GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();
                    //objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), useremail, username, "", EmailId, "", "", "Group Invitation", html, usernameSend, pass);
                    MailSender objMailSender = new MailSender();
                    string ret = objMailSender.SendChangePasswordMail(EmailId, html, "Group Invitation");
                    return new JavaScriptSerializer().Serialize(team);
                }
                else
                {
                    return "";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return "Something Went Wrong";
            }
        }
示例#2
0
        public string AddTeam(string UserId, string InviteStatus, string FirstName, string LastName, string EmailId, string AccessLevel, string GroupId, string useremail, string username)
        {
            try
            {
                if (!teamrepo.checkTeamExists(EmailId, Guid.Parse(UserId), Guid.Parse(GroupId)))
                {
                    Domain.Socioboard.Domain.Groups _Groups = objGroupsRepository.getGroupDetailsbyId(Guid.Parse(UserId), Guid.Parse(GroupId));
                    team.Id               = Guid.NewGuid();
                    team.UserId           = Guid.Parse(UserId);
                    team.InviteStatus     = Convert.ToInt32(InviteStatus);
                    team.InviteDate       = DateTime.Now;
                    team.StatusUpdateDate = DateTime.Now;
                    team.GroupId          = Guid.Parse(GroupId);
                    team.StatusUpdateDate = DateTime.Now;
                    team.FirstName        = FirstName;
                    team.LastName         = LastName;
                    team.EmailId          = EmailId;
                    team.AccessLevel      = AccessLevel;
                    teamrepo.addNewTeam(team);
                    string check = team.Id.ToString();

                    string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/GroupInvitation.html");
                    string html     = File.ReadAllText(mailpath);
                    html = html.Replace("[group_name]", _Groups.GroupName);
                    html = html.Replace("[join link]", "Home/Index?teamid=" + team.Id.ToString());
                    //string usernameSend = ConfigurationManager.AppSettings["Mandrillusername"];
                    //string host = ConfigurationManager.AppSettings["Mandrillhost"];
                    //string port = ConfigurationManager.AppSettings["Mandrillport"];
                    //string pass = ConfigurationManager.AppSettings["Mandrillpassword"];
                    //GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();
                    //objMailHelper.SendMailByMandrill(host, Convert.ToInt32(port), useremail, username, "", EmailId, "", "", "Group Invitation", html, usernameSend, pass);
                    MailSender objMailSender = new MailSender();
                    string     ret           = objMailSender.SendChangePasswordMail(EmailId, html, "Group Invitation");
                    return(new JavaScriptSerializer().Serialize(team));
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("Something Went Wrong");
            }
        }
示例#3
0
        public string GetAllNewsLetters()
        {
            MailSender _MailSender = new MailSender();

            //List<NewsLetter> = ObjNewsLetterRepository.getAllNewsLetter();
            try
            {
                List <Domain.Socioboard.Domain.NewsLetter> lstNewsLetter = new List <Domain.Socioboard.Domain.NewsLetter>();
                lstNewsLetter = objNewsLetterRepository.getAllNewsLetters();
                if (lstNewsLetter.Count == 0)
                {
                    return("No record found");
                }
                foreach (Domain.Socioboard.Domain.NewsLetter item in lstNewsLetter)
                {
                    //string ret = string.Empty;
                    try
                    {
                        objNewsLetter = new Domain.Socioboard.Domain.NewsLetter();
                        string ret = _MailSender.SendAddNewsLatterMail(item.Email, item.NewsLetterBody, item.Subject);
                        if (ret == "Success")
                        {
                            objNewsLetter.Id         = item.Id;
                            objNewsLetter.SendStatus = true;
                            objNewsLetterRepository.UpdateNewsLetter(objNewsLetter);
                        }
                        //SendMail(item);
                        //SendNewsLetter(item.NewsLetterBody, item.Subject, item.UserId.ToString(), item.Id.ToString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error : " + ex.StackTrace);
                    }
                }
                return("New Latter Sent successfully");
            }
            catch (Exception ex)
            {
                return("Please try Again");
            }
        }
示例#4
0
        public string SendInvitationMail(string SenderEmail, string SenderName, string FriendsEmail)
        {
            string ret      = string.Empty;
            string mailbody = string.Empty;

            //string code = Utility.GenerateRandomUniqueString();
            Domain.Socioboard.Domain.User _user = userRepo.getUserInfoByEmail(SenderEmail);
            string mailpath = HttpContext.Current.Server.MapPath("~/Layouts/Mails/Invitationmailer_template.html");

            mailbody = File.ReadAllText(mailpath);
            mailbody = mailbody.Replace("[FriendName]", SenderName);
            if (_user.UserCode == null || _user.UserCode == "")
            {
                string code   = Utility.GenerateRandomUniqueString();
                int    retint = userRepo.UpdateCode(_user.Id, code);
                _user = userRepo.getUsersById(_user.Id);
            }
            mailbody = mailbody.Replace("[CODE]", _user.UserCode);
            mailbody = mailbody.Replace("[DomainName]", ConfigurationManager.AppSettings["DomainName"]);
            //string pass = ConfigurationManager.AppSettings["Mandrillpassword"];
            //GlobusMailLib.MailHelper objMailHelper = new GlobusMailLib.MailHelper();
            //ret = objMailHelper.SendInvitationMailByMandrill(SenderEmail, SenderName, FriendsEmail, pass, mailbody);
            string     subject       = "Your friend " + SenderName + " has invited you to join " + ConfigurationManager.AppSettings["DefaultGroupName"];
            MailSender apimailsender = new MailSender();

            ret = apimailsender.SendChangePasswordMail(FriendsEmail, mailbody, subject);
            //Domain.Socioboard.Domain.Invitation objInvite = new Domain.Socioboard.Domain.Invitation();
            //Domain.Socioboard.Domain.User _user = userRepo.getUserInfoByEmail(SenderEmail);
            //objInvite.Id=Guid.NewGuid();
            //objInvite.SenderEmail=_user.EmailId;
            //objInvite.SenderUserId=_user.Id;
            //objInvite.FriendEmail=FriendsEmail;
            //objInvite.SendInvitationDate = DateTime.Now;
            //objInvite.InvitationCode = code;
            //InvitationRepo.Add(objInvite);
            return(ret);
        }
        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();
            }

        }