Esempio n. 1
0
    public static string DeleteEvent(string id)
    {
        try
        {
            ScheduledEvent scheduledevent = ScheduledEvent.AppointmentByID(id, TimeZoneInfo.Utc);
            if (scheduledevent == null)
            {
                return(Resources.Schedule.errItemNotFound);
            }

            string szUser = HttpContext.Current.User.Identity.Name;

            if (!scheduledevent.CanEdit(szUser))
            {
                throw new MyFlightbookException(Resources.Schedule.ErrUnauthorizedEdit);
            }

            if (scheduledevent.FDelete())
            {
                // Send any notifications - but do it on a background thread so that we can return quickly
                new Thread(() =>
                {
                    Club c = Club.ClubWithID(scheduledevent.ClubID);
                    c.NotifyOfDelete(scheduledevent, szUser);
                }).Start();
            }
            else
            {
                throw new MyFlightbookException(scheduledevent.LastError);
            }
        }
        catch (MyFlightbookException ex)
        {
            return(ex.Message);
        }
        return(string.Empty);
    }