Ejemplo n.º 1
0
 public ActionResult AddGroup(string Groupname)
 {
     DataAccess.Tnsmtp_Contactgroup tnsmtp_Contactgroup = new DataAccess.Tnsmtp_Contactgroup();
     tnsmtp_Contactgroup.Groupname = Groupname;
     tnsmtp_Contactgroup.Userid    = SysUser.UserId;
     tnsmtp_Contactgroup.Status    = (int)Entites.Status.正常;
     if (!tnsmtp_Contactgroup.Insert())
     {
         return(FailResult());
     }
     return(SuccessResult());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加联系人表数据
        /// </summary>
        /// <returns></returns>
        private bool AddContactTable(Tnsmtp_EmailMap model)
        {
            DataAccess.Tnsmtp_Contact tnsmtp_Contact = new DataAccess.Tnsmtp_Contact();
            tnsmtp_Contact.ReferenceTransactionFrom(this.Transaction);
            if (tnsmtp_Contact.SelectByEmail(model.Userid, model.Inmail))
            {
                model.RecId = tnsmtp_Contact.ContactId;
            }


            if (!model.RecId.HasValue)
            {
                #region 如果用户没有 "常用联系人" 这个组则添加这个组


                DataAccess.Tnsmtp_Contactgroup tnsmtp_Contactgroup = new DataAccess.Tnsmtp_Contactgroup();
                tnsmtp_Contactgroup.ReferenceTransactionFrom(this.Transaction);
                if (!tnsmtp_Contactgroup.SelectByGroupName(model.Userid, "常用联系人"))
                {
                    tnsmtp_Contactgroup.Groupname = "常用联系人";
                    tnsmtp_Contactgroup.Userid    = model.Userid;
                    tnsmtp_Contactgroup.Status    = 0;
                    if (!tnsmtp_Contactgroup.Insert())
                    {
                        Alert("添加常用联系人分组失败");
                        return(false);
                    }
                }


                #endregion


                #region 添加联系人

                tnsmtp_Contact.ContactName = model.Inmail;
                tnsmtp_Contact.Email       = model.Inmail;
                tnsmtp_Contact.Gid         = tnsmtp_Contactgroup.Gid;
                tnsmtp_Contact.Status      = 0;
                tnsmtp_Contact.UserId      = model.Userid;
                tnsmtp_Contact.CateId      = 1;

                if (!tnsmtp_Contact.Insert())
                {
                    Alert("添加常用联系人失败");
                    return(false);
                }
                #endregion
            }

            return(true);
        }