Ejemplo n.º 1
0
        /// <summary>
        /// This method will call the Event Resource class method to Delete the event in the database
        /// And send the email to all admin about the event deletion for all public event and also
        /// resend the mail to all guest list about teh event deletion
        /// </summary>
        /// <param name="objEvent">An Event Object which contain event id which wants to delete</param>
        public void DeleteEvent(Events objEvent)
        {
            try
            {
                EventResource objEventRes = new EventResource();

                // First get the Guest List for the event which are going to update
                Events guestList = objEventRes.GetEventGuestList(objEvent);
                TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance;
                //string Servername = (string)stateManager.Get("SERVERNAME", TributesPortal.Utilities.StateManager.State.Session);

                // Now Delete the Event and Guest List
                objEventRes.DeleteEvent(objEvent);

                // Send the email to all the adminstrator that event has been updated
                if ((objEvent != null) && (objEvent.CustomError == null) && (objEvent.IsPrivate == false))
                {
                    string EmailSubject = string.Empty;

                    if (!string.IsNullOrEmpty(objEvent.LastName))
                        EmailSubject = objEvent.FirstName + " " + objEvent.LastName + " cancelled the event \"" + objEvent.EventName + "\"";
                    else
                        EmailSubject = objEvent.FirstName + " cancelled the event \"" + objEvent.EventName + "\"";
                    string EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + objEvent.FirstName + " " + objEvent.LastName + " cancelled the event \"" + objEvent.EventName + "\"" + " in the " + objEvent.TributeName + " " + objEvent.TributeType + "  Tribute." +
                        "<br/><br/>" + "To view the tribute, follow the link below:" + "<br/>";
                    //string href = "<a href='http://" + objEvent.TributeType.Trim().ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "'> http://" + Servername + "/" + objEvent.TributeURL + "</a>" + "<br/> <br/>" + "----" + "<br/>" + "Your Tribute Team</p></font>";
                    string href = "<a href='http://" + objEvent.TributeType.Trim().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "'> http://" + objEvent.TributeType.Trim().ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "</a>" + "<br/> <br/>" + "----" + "<br/>" + "Your Tribute Team</p></font>";
                    EmailBody += href;

                    SendEmail(objEvent.TributeId, EmailSubject, EmailBody);
                }

                if (guestList.EventAwaiting != null)
                {
                    // Send the email to all the Guest who are invited for the event that event has been updated
                    for (int i = 0; i < guestList.EventAwaiting.Count; i++)
                    {
                        Events emailEvent = new Events();
                        emailEvent.EventID = objEvent.EventID;
                        emailEvent.EmailId = guestList.EventAwaiting[i].UserName.ToString();
                        string EmailSubject = string.Empty;

                        if (!string.IsNullOrEmpty(objEvent.LastName))
                            EmailSubject = objEvent.FirstName + " " + objEvent.LastName + " cancelled the event \"" + objEvent.EventName + "\"";
                        else
                            EmailSubject = objEvent.FirstName + " cancelled the event \"" + objEvent.EventName + "\"";

                        string EmailBody = "<font style='font-size: 12px; font-family:Lucida Sans;'><p>" + objEvent.FirstName + " " + objEvent.LastName + "  cancelled the event \"" + objEvent.EventName + "\"" + " in the " + objEvent.TributeName + " " + objEvent.TributeType + " Tribute." +
                        "<br/><br/>" + "To view the tribute, follow the link below:" + "<br/>";
                        //string href = "<a href='http://" + objEvent.TributeType.Trim().ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "'> http://" + Servername + "/" + objEvent.TributeURL + "</a>" + "<br/> <br/>" + "----" + "<br/>" + "Your Tribute Team</p></font>";
                        string href = "<a href='http://" + objEvent.TributeType.Trim().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "'> http://" + objEvent.TributeType.Trim().ToLower().Replace("new baby", "newbaby") + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "</a>" + "<br/> <br/>" + "----" + "<br/>" + "Your Tribute Team</p></font>";
                        //string href = "<a href='http://" + objEvent.TributeType.Trim().ToLower() + "." + WebConfig.TopLevelDomain + "/" + objEvent.TributeURL + "'> http://" + objEvent.TributeType.Trim().ToLower() + "." + WebConfig.TopLevelDomain + "/" + "/" + objEvent.TributeURL + "</a>" + "<br/> <br/>" + "----" + "<br/>" + "Your Tribute Team</p></font>";
                        EmailBody += href;

                        EmailMessages objEmail = EmailMessages.Instance;
                        bool val = objEmail.SendMessages("Your Tribute<" + WebConfig.NoreplyEmail + ">", emailEvent.EmailId, EmailSubject, CreateBody(EmailBody), EmailMessages.TextFormat.Html.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }