Exemplo n.º 1
0
        public ActionResult AddTeamMember(string email)
        {
            User   objUser         = (User)Session["User"];
            string selectedgroupid = Session["selectedgroupid"].ToString();

            Api.Team.Team ApiobjTeam  = new Api.Team.Team();
            Api.User.User ApiobjUser  = new Api.User.User();
            User          objuserinfo = (User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(email), typeof(User)));

            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];
                }
                ApiobjTeam.AddTeam(objuserinfo.Id.ToString(), "0", fname, lname, email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
            }
            else
            {
                ApiobjTeam.AddTeam(Guid.NewGuid().ToString(), "0", "", "", email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
            }
            return(Content("_AcceptedUserPartial"));
        }
        //public ActionResult AddTeamMember(string email)
        //{
        //    string response = string.Empty;

        //    User objUser = (User)Session["User"];
        //    string selectedgroupid = Session["selectedgroupid"].ToString();
        //    Api.Team.Team ApiobjTeam = new Api.Team.Team();
        //    Api.User.User ApiobjUser = new Api.User.User();
        //    User objuserinfo = (User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(email), typeof(User)));
        //    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];
        //        }
        //       response = ApiobjTeam.AddTeam(objuserinfo.Id.ToString(), "0", fname, lname, email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
        //    }
        //    else
        //    {
        //        response = ApiobjTeam.AddTeam(Guid.NewGuid().ToString(), "0", "", "", email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
        //    }
        //    //return Content("_AcceptedUserPartial");
        //    return Content(response);
        //}

        // Edited by Antima[6/11/2014]

        public ActionResult AddTeamMember(string email)
        {
            //string[] arr = new string[]{};
            string SentMails = string.Empty;
            try
            {
                List<string> arr = new List<string>();
                string[] arr1 = new string[] { };
                string NotSentMails = string.Empty;
                User objUser = (User)Session["User"];
                string selectedgroupid = string.Empty;
                if (Session["selectedgroupid"] == null || Session["selectedgroupid"] == "")
                {
                    selectedgroupid = Request.QueryString["groupid"];
                }
                else
                {
                    selectedgroupid = Session["selectedgroupid"].ToString();
                }
                Api.Team.Team ApiobjTeam = new Api.Team.Team();
                Api.User.User ApiobjUser = new Api.User.User();
                if (email.Contains(','))
                {
                    arr = email.Split(',').ToList();
                }
                else
                {
                    //arr[0] = email;
                    arr.Add(email);
                }

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

                    string res = "";
                    User objuserinfo = (User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(arr1[0]), typeof(User)));

                    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);
                    }
                    else
                    {
                        res = ApiobjTeam.AddTeam(objUser.Id.ToString(), "0", arr1[1], arr1[2], arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                    }
                    //SentMails += res + ',';

                    if (!string.IsNullOrEmpty(res) && SentMails != "Something Went Wrong")
                    {
                        Domain.Socioboard.Domain.Team objDomainTeam = (Domain.Socioboard.Domain.Team)new JavaScriptSerializer().Deserialize(res, typeof(Domain.Socioboard.Domain.Team));
                        if (objDomainTeam != null)
                        {
                            SentMails += objDomainTeam.EmailId + ',';
                        }
                    }
                    else
                    {
                        NotSentMails += arr1[0] + ',';
                    }
                }
                SentMails = "{\"SentMails\":" + "\"" + SentMails + "\",\"NotSentMails\":" + "\"" + NotSentMails + "\"}";
            }
            catch (Exception ex)
            {
            }

            return Content(SentMails);
        }
Exemplo n.º 3
0
        //public ActionResult AddTeamMember(string email)
        //{
        //    string response = string.Empty;

        //    User objUser = (User)Session["User"];
        //    string selectedgroupid = Session["selectedgroupid"].ToString();
        //    Api.Team.Team ApiobjTeam = new Api.Team.Team();
        //    Api.User.User ApiobjUser = new Api.User.User();
        //    User objuserinfo = (User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(email), typeof(User)));
        //    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];
        //        }
        //       response = ApiobjTeam.AddTeam(objuserinfo.Id.ToString(), "0", fname, lname, email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
        //    }
        //    else
        //    {
        //        response = ApiobjTeam.AddTeam(Guid.NewGuid().ToString(), "0", "", "", email, "", selectedgroupid, objUser.EmailId, objUser.UserName);
        //    }
        //    //return Content("_AcceptedUserPartial");
        //    return Content(response);
        //}

        // Edited by Antima[6/11/2014]

        public ActionResult AddTeamMember(string email)
        {
            //string[] arr = new string[]{};
            string SentMails = string.Empty;

            try
            {
                List <string> arr             = new List <string>();
                string[]      arr1            = new string[] { };
                string        NotSentMails    = string.Empty;
                User          objUser         = (User)Session["User"];
                string        selectedgroupid = string.Empty;
                if (Session["selectedgroupid"] == null || Session["selectedgroupid"] == "")
                {
                    selectedgroupid = Request.QueryString["groupid"];
                }
                else
                {
                    selectedgroupid = Session["selectedgroupid"].ToString();
                }
                Api.Team.Team ApiobjTeam = new Api.Team.Team();
                Api.User.User ApiobjUser = new Api.User.User();
                if (email.Contains(','))
                {
                    arr = email.Split(',').ToList();
                }
                else
                {
                    //arr[0] = email;
                    arr.Add(email);
                }

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

                    string res         = "";
                    User   objuserinfo = (User)(new JavaScriptSerializer().Deserialize(ApiobjUser.getUserInfoByEmail(arr1[0]), typeof(User)));

                    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);
                    }
                    else
                    {
                        res = ApiobjTeam.AddTeam(objUser.Id.ToString(), "0", arr1[1], arr1[2], arr1[0], "", selectedgroupid, objUser.EmailId, objUser.UserName);
                    }
                    //SentMails += res + ',';

                    if (!string.IsNullOrEmpty(res) && SentMails != "Something Went Wrong")
                    {
                        Domain.Socioboard.Domain.Team objDomainTeam = (Domain.Socioboard.Domain.Team) new JavaScriptSerializer().Deserialize(res, typeof(Domain.Socioboard.Domain.Team));
                        if (objDomainTeam != null)
                        {
                            SentMails += objDomainTeam.EmailId + ',';
                        }
                    }
                    else
                    {
                        NotSentMails += arr1[0] + ',';
                    }
                }
                SentMails = "{\"SentMails\":" + "\"" + SentMails + "\",\"NotSentMails\":" + "\"" + NotSentMails + "\"}";
            }
            catch (Exception ex)
            {
            }

            return(Content(SentMails));
        }