コード例 #1
0
        /// <summary>
        /// 删除组织机构
        /// </summary>
        /// <param name="organization">要删除的组织机构</param>
        public void DeleteOrganization(Organization organization)
        {
            int    code    = 0;
            string strName = GetOrganization(organization.OrganizationId).ShortName;

            dal.DeleteOrganization(organization.OrganizationId, ref code);
            if (code == 0)
            {
                objLogBll.WriteLog("删除组织机构“" + strName + "”基本信息");
            }
        }
コード例 #2
0
        public IHttpActionResult CancelCreateOrganizationRequest(int organizationId)
        {
            try
            {
                bool isSuccess;
                OrganizationBasicInfo organizationBasic;
                // Delete create request
                using (var db = new OrganizationDAL())
                {
                    //get inforamation of organziation Creator
                    organizationBasic = db.GetFullOrganizationBasicInformation(organizationId);

                    isSuccess = db.DeleteOrganization(organizationId);
                }



                //Send mail to Creator to anounce that admin reject create organization request
                if (isSuccess)
                {
                    //khai bao bien
                    var    fromAddress  = new MailAddress(WsConstant.OrganizationRegistration.AdminEmail, WsConstant.OrganizationRegistration.WsAdmin);
                    var    toAddress    = new MailAddress(organizationBasic.Creator.Email, organizationBasic.Creator.UserName);
                    string fromPassword = WsConstant.OrganizationRegistration.AdminEmailPass;
                    string subject      = WsConstant.OrganizationRegistration.EmailSubjectRejectRegistration;
                    string body         = WsConstant.OrganizationRegistration.EmailContentFirst + "Yêu cầu tạo tổ chức : '" + organizationBasic.OrganizationName + "' " + WsConstant.OrganizationRegistration.EmailContentRejectRegistration;
                    //xu li gui mail
                    var smtp = new SmtpClient
                    {
                        Host                  = "smtp.gmail.com",
                        Port                  = 587,
                        EnableSsl             = true,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Timeout               = 30000,
                        Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
                    };
                    using (var message = new MailMessage(fromAddress, toAddress)
                    {
                        Subject = subject,
                        Body = body
                    })
                    {
                        smtp.Send(message);
                    }
                }

                return(Ok(new HTTPMessageDTO {
                    Status = WsConstant.HttpMessageType.SUCCESS, Data = isSuccess
                }));
            }
            catch (Exception)
            {
                return(Ok(new HTTPMessageDTO {
                    Status = WsConstant.HttpMessageType.ERROR
                }));
            }
        }