コード例 #1
0
        public void Test_Delete()
        {
            var eventData   = _fixture.CreateMany <byte>().ToArray();
            var partitionId = _fixture.Create <int>();
            var type        = _fixture.Create <EventType>();

            _events.Add(partitionId, TestConstants.TestAdminUserId, type, EventState.Emailing, eventData);
            var data = _events.GetNext(type, partitionId);

            _events.Delete(data.Id);

            data = _events.GetNext(type, partitionId);
            data.Should().BeNull();
        }
コード例 #2
0
ファイル: EventsStorage.cs プロジェクト: kovavka/HSEvents
 public void Delete(long[] ids)
 {
     using (var repo = new EventRepository())
     {
         repo.Delete(ids);
     }
 }
コード例 #3
0
ファイル: EventsStorage.cs プロジェクト: kovavka/HSEvents
 public void Delete(int id)
 {
     using (var repo = new EventRepository())
     {
         repo.Delete(id);
     }
 }
コード例 #4
0
      public ActionResult Delete(int id)
      {
          var efEvent = _eventRepository.FindBy(i => i.Id == id).SingleOrDefault();

          _eventRepository.Delete(id);
          return(RedirectToAction("ManageIndex"));
      }
コード例 #5
0
ファイル: EventWorker.cs プロジェクト: drayv/Pic-Boy-1500
 public int DeleteEvent(Event eventToDelete)
 {
     using (var repo = new EventRepository())
     {
         repo.Delete(eventToDelete);
         return repo.Save();
     }
 }
コード例 #6
0
 public void DeleteEvent(int eventId)
 {
     using (var uow = UnitOfWorkProvider.Create())
     {
         _eventRepository.Delete(eventId);
         uow.Commit();
     }
 }
コード例 #7
0
ファイル: EventWorker.cs プロジェクト: drayv/Pic-Boy-1500
 public int DeleteEvent(Event eventToDelete)
 {
     using (var repo = new EventRepository())
     {
         repo.Delete(eventToDelete);
         return(repo.Save());
     }
 }
コード例 #8
0
        public void DeleteTest()
        {
            var mockContext = GetMockContext();
            var repository  = new EventRepository(mockContext.Object);
            var item        = mockContext.Object.Events.First();

            repository.Delete(item);
            Assert.Null(mockContext.Object.Events.Find(item.Id));
        }
コード例 #9
0
        public ActionResult DeleteEvent(int id)
        {
            EventRepository eventRepository = RepositoryFactory.GetEventRepository();
            Event           even            = eventRepository.GetById(id);

            eventRepository.Delete(even);

            return(RedirectToAction("Index", "EventManagement"));
        }
コード例 #10
0
        public ActionResult Delete(int id)
        {
            var eventRepository = new EventRepository();
            var entity          = eventRepository.GetById(id);

            eventRepository.Delete(entity);

            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public void Delete()
        {
            Planning planningOutput = _planningRepository.Create(_planningInput);
            Event    eventInput     = new Event(0, 1, planningOutput.Id, "label", "20-05-05 00:00:00", "20-05-05 00:00:00");

            Event eventOutput = _eventRepository.Create(eventInput);
            bool  isDeleted   = _eventRepository.Delete(eventOutput.Id);

            Assert.True(isDeleted);
        }
コード例 #12
0
 public void DeleteItem(Event item)
 {
     if (item != null)
     {
         if (_eventRepository.Exists(item))
         {
             _eventRepository.Delete(item);
         }
     }
 }
コード例 #13
0
        public JsonResult DeleteEvent(int eventID)
        {
            Events events = new Events();

            eventRepository.Delete(eventID);
            var status = true;

            return(new JsonResult {
                Data = new { status = status }
            });
        }
コード例 #14
0
        /// <summary>
        /// Permanently delete all events from the data store that are system-wide (that is, not associated with a specific gallery) and also
        /// those events belonging to the specified <paramref name="galleryId" />.
        /// </summary>
        /// <param name="galleryId">The gallery ID.</param>
        public static void ClearEventLog(int galleryId)
        {
            using (var repo = new EventRepository())
            {
                foreach (var eDto in repo.Where(e => e.FKGalleryId == galleryId || e.Gallery.IsTemplate))
                {
                    repo.Delete(eDto);
                }

                repo.Save();
            }
        }
コード例 #15
0
ファイル: EventController.cs プロジェクト: dSiles98/CyclePath
 public IActionResult DeleteEvent(int id)
 {
     try
     {
         eventRepository.Delete(id);
         return(Ok());
     }
     catch (Exception exe)
     {
         return(BadRequest(exe.Message));
     }
 }
コード例 #16
0
        /// <summary>
        /// Permanently delete all events from the data store that are system-wide (that is, not associated with a specific gallery) and also
        /// those events belonging to the specified <paramref name="galleryId" />.
        /// </summary>
        /// <param name="galleryId">The gallery ID.</param>
        public static void ClearEventLog(int galleryId)
        {
            using (var repo = new EventRepository())
            {
                foreach (var eDto in repo.Where(e => e.FKGalleryId == galleryId || e.Gallery.IsTemplate))
                {
                    repo.Delete(eDto);
                }

                repo.Save();
            }
        }
コード例 #17
0
        public ActionResult Delete(EventsDeleteViewModel model)
        {
            EventRepository repository = new EventRepository();

            if (model.Id.ToString() != String.Empty)
            {
                repository.Delete(model.Id);
            }


            return(RedirectToAction("Index"));
        }
コード例 #18
0
        /// <summary>
        /// Permanently remove the specified event from the data store.
        /// </summary>
        /// <param name="eventId">The value that uniquely identifies this application event (<see cref="IEvent.EventId"/>).</param>
        public static void Delete(int eventId)
        {
            using (var repo = new EventRepository())
            {
                var aeDto = repo.Find(eventId);

                if (aeDto != null)
                {
                    repo.Delete(aeDto);
                    repo.Save();
                }
            }
        }
コード例 #19
0
        public IHttpActionResult DeleteEvent(int id)
        {
            Event @event = repository.GetById(id);

            if (@event == null)
            {
                return(NotFound());
            }

            repository.Delete(@event);

            return(Ok(@event));
        }
コード例 #20
0
        /// <summary>
        /// Permanently remove the specified event from the data store.
        /// </summary>
        /// <param name="eventId">The value that uniquely identifies this application event (<see cref="IEvent.EventId"/>).</param>
        public static void Delete(int eventId)
        {
            using (var repo = new EventRepository())
            {
                var aeDto = repo.Find(eventId);

                if (aeDto != null)
                {
                    repo.Delete(aeDto);
                    repo.Save();
                }
            }
        }
コード例 #21
0
ファイル: EventModel.cs プロジェクト: Khushi-Juchani/FreeNew
 public bool DeleteEvent(int EventID)
 {
     try
     {
         eventRepository.Delete(EventID);
         eventRepository.Save();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #22
0
        public IHttpActionResult Delete(int id)
        {
            EventRepository repository = new EventRepository();
            Event           _event     = repository.GetById(id);

            if (_event == null)
            {
                return(NotFound());
            }

            repository.Delete(_event);

            return(Ok());
        }
コード例 #23
0
        public IHttpActionResult Delete(Guid id)
        {
            try
            {
                var eventItem = _eventRepository.GetById(id);

                _eventRepository.Delete(id);
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }

            return(Content(HttpStatusCode.NoContent, "Gebeurtenis is met succes verwijderd."));
        }
コード例 #24
0
        public IActionResult DeleteConfirmed(EventDTO obj)
        {
            try
            {
                bool result = _repository.Delete(obj.Id, _userManager.GetUserName(this.User));
            }
            catch (ConcurrencyException ex)
            {
                ModelState.AddModelError("", ex.Message);

                return(View(obj));
            }


            return(RedirectToAction(nameof(Index)));
        }
コード例 #25
0
            public void Execute(IJobExecutionContext context)
            {
                log.Info("EventPublisher is executing");

                var eventRepository = new EventRepository(_store.OpenSession());
                var events          = eventRepository.ListAll();

                // Process the new events
                Parallel.ForEach(events, Notify);

                // Delete the recevied events
                Parallel.ForEach(events, evt => { if (evt.Recevied)
                                                  {
                                                      eventRepository.Delete(evt);
                                                  }
                                 });
            }
コード例 #26
0
        public IHttpActionResult Delete(int id)
        {
            var headers = Request.Headers;

            if (!headers.Contains("auth_token") && !headers.Contains("fb_auth"))
            {
                return(Ok(new { errorCode = "66", message = "unauthorized" }));
            }
            if (headers.Contains("auth_token"))
            {
                var token = headers.GetValues("auth_token").First();
                if (!_authToken.VerifyToken(token))
                {
                    return(Ok(new { errorCode = "66", message = "unauthorized" }));
                }
            }
            _eventRepository.Delete(id);
            return(Ok());
        }
コード例 #27
0
        /// <summary>
        /// If automatic log size trimming is enabled and the log contains more items than the specified limit, delete the oldest
        /// event records. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero. Return the number of
        /// items that were deleted, if any.
        /// </summary>
        /// <param name="maxNumberEventItems">The maximum number of event items that should be stored in the log. If the count exceeds
        /// this amount, the oldest items are deleted. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero.</param>
        /// <returns>Returns the number of items that were deleted from the log.</returns>
        public static int ValidateLogSize(int maxNumberEventItems)
        {
            if (maxNumberEventItems == 0)
            {
                return(0);                // Auto trimming is disabled, so just return.
            }
            var events = GetAppEvents();

            var numErrors       = events.Count;
            var numErrorDeleted = 0;

            using (var repo = new EventRepository())
            {
                while (numErrors > maxNumberEventItems)
                {
                    // Find oldest event and delete it.
                    var aeDto = repo.Find(events[numErrors - 1].EventId);

                    if (aeDto != null)
                    {
                        repo.Delete(aeDto);
                    }

                    numErrors--;

                    numErrorDeleted++;
                }

                try
                {
                    repo.Save();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    // When multiple threads call this method, the 2nd thread might try to delete rows that were deleted by the
                    // first thread. This isn't a problem, but let's log it in case something else is happening that we should be alerted to.
                    RecordEvent(String.Concat("The following error occurred while trimming the event log. It can be ignored if it occurs infrequently. ", GetExceptionDetails(ex)));
                }
            }

            return(numErrorDeleted);
        }
コード例 #28
0
        public void Delete(Event obj)
        {
            if (null != obj.Images)
            {
                for (int i = obj.Images.Count - 1; i >= 0; i--)
                {
                    EventImage image = _imageRepository.Get(obj.Images[i].Id);
                    _imageRepository.Delete(image);

                    if (File.Exists(image.Path))
                    {
                        File.Delete(image.Path);
                    }
                }

                obj.Images.Clear();
            }

            _eventRepository.Delete(obj);
        }
コード例 #29
0
        public ActionResult Delete(Event ev)
        {
            try
            {
                var pictures = repoEvent.GetSet().Where(e => e.Id == ev.Id).Include(e => e.Pictures).First().Pictures;
                foreach (Picture p in pictures)
                {
                    var FilePath = Path.Combine(Server.MapPath("~/Content/media/img/") + p.FileName);
                    System.IO.File.Delete(FilePath);
                }
                Context.Pictures.RemoveRange(pictures);
                Context.SaveChanges();
                repoEvent.Delete(ev.Id);


                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index"));
            }
        }
コード例 #30
0
        public void DeleteEventTest()
        {
            // Arrange
            HollywoodTestEntities dataContext     = new HollywoodTestEntities();
            EventRepository       eventRepository = new EventRepository(dataContext);
            Event _event = new Event()
            {
                TournamentID     = 1,
                EventName        = "Delete Event Data Access Unit Test",
                EventNumber      = 1,
                EventDateTime    = Convert.ToDateTime("2019-04-16"),
                EventEndDateTime = Convert.ToDateTime("2019-06-16"),
                AutoClose        = true,
            };

            // Act
            int  eventId   = eventRepository.Create(_event);
            bool isDeleted = eventRepository.Delete(eventId);

            // Assert
            Assert.IsTrue(isDeleted);
        }
コード例 #31
0
        public ActionResult DeleteConfirmed(Event ev)
        {
            try
            {
                var pictures = from p in Context.Pictures select p;

                foreach (Picture p in pictures)
                {
                    if (p.Id == ev.Id)
                    {
                        Context.Pictures.Remove(p);
                    }
                }

                repoEvent.Delete(ev.Id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View("Index"));
            }
        }
コード例 #32
0
        /// <summary>
        /// If automatic log size trimming is enabled and the log contains more items than the specified limit, delete the oldest
        /// event records. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero. Return the number of
        /// items that were deleted, if any.
        /// </summary>
        /// <param name="maxNumberEventItems">The maximum number of event items that should be stored in the log. If the count exceeds
        /// this amount, the oldest items are deleted. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero.</param>
        /// <returns>Returns the number of items that were deleted from the log.</returns>
        public static int ValidateLogSize(int maxNumberEventItems)
        {
            if (maxNumberEventItems == 0)
            {
                return(0);                // Auto trimming is disabled, so just return.
            }
            var numErrorDeleted = 0;

            lock (_sharedLock)
            {
                using (var repo = new EventRepository())
                {
                    foreach (var e in repo.All.OrderByDescending(ae => ae.EventId).Skip(maxNumberEventItems))
                    {
                        repo.Delete(e);
                        numErrorDeleted++;
                    }

                    repo.Save();
                }
            }

            return(numErrorDeleted);
        }
コード例 #33
0
 public void DeleteEvent(string eventId)
 {
     EventRepository.Delete(eventId);
 }
コード例 #34
0
        /// <summary>
        /// If automatic log size trimming is enabled and the log contains more items than the specified limit, delete the oldest 
        /// event records. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero. Return the number of
        /// items that were deleted, if any.
        /// </summary>
        /// <param name="maxNumberEventItems">The maximum number of event items that should be stored in the log. If the count exceeds 
        /// this amount, the oldest items are deleted. No action is taken if <paramref name="maxNumberEventItems"/> is set to zero.</param>
        /// <returns>Returns the number of items that were deleted from the log.</returns>
        public static int ValidateLogSize(int maxNumberEventItems)
        {
            if (maxNumberEventItems == 0)
                return 0; // Auto trimming is disabled, so just return.

            var events = GetAppEvents();

            var numErrors = events.Count;
            var numErrorDeleted = 0;

            using (var repo = new EventRepository())
            {
                while (numErrors > maxNumberEventItems)
                {
                    // Find oldest event and delete it.
                    var aeDto = repo.Find(events[numErrors - 1].EventId);

                    if (aeDto != null)
                        repo.Delete(aeDto);

                    numErrors--;

                    numErrorDeleted++;
                }

                try
                {
                    repo.Save();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    // When multiple threads call this method, the 2nd thread might try to delete rows that were deleted by the
                    // first thread. This isn't a problem, but let's log it in case something else is happening that we should be alerted to.
                    RecordEvent(String.Concat("The following error occurred while trimming the event log. It can be ignored if it occurs infrequently. ", GetExceptionDetails(ex)));
                }
            }

            return numErrorDeleted;
        }