public string DeleteEvent(DeleteEventViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return("Błąd");
            }

            var eventToDelete = _db.Events.Find(vm.EventId);

            if (eventToDelete == null)
            {
                return("Błąd");
            }

            if (eventToDelete.Date < DateTime.Now.AddMinutes(1))
            {
                return("Błąd");
            }

            _db.Events.Remove(eventToDelete);
            _db.SaveChanges();

            try
            {
                _formFilesManagement.DeleteWholeEventFolder(eventToDelete.EventId);
            }
            catch (DirectoryNotFoundException) { } // stock files

            return("/OrganizerPanelArea/OrganizerPanel/EventsList");
        }
Beispiel #2
0
        /// <summary>
        /// Deleted an Timeline Event
        /// </summary>
        /// <param name="Id">String Id of event to be deleted</param>
        private void Delete(string Id)
        {
            DeleteEventViewModel delete = new DeleteEventViewModel(Id);
            var request = new RestRequest("TimelineEvent/Delete");

            if (!PutRequest(request, delete).Equals("OK")) //Error Handling
            {
                throw new System.ArgumentException("Parameter cannot be null", "original");
            }
        }