public void GetPaged()
        {
            RemoveData();

            var events = new List <PersistentEvent>();

            for (int i = 0; i < 6; i++)
            {
                events.Add(EventData.GenerateEvent(projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId, stackId: TestConstants.StackId, occurrenceDate: DateTime.Now.Subtract(TimeSpan.FromMinutes(i))));
            }

            _repository.Add(events);
            _client.Refresh(r => r.Force(false));
            Assert.Equal(events.Count, _repository.Count());

            var results = _repository.GetByOrganizationId(TestConstants.OrganizationId, new PagingOptions().WithLimit(2).WithAfter(String.Concat(events[1].Date.UtcTicks.ToString(), "-", events[1].Id)));

            Assert.Equal(2, results.Count);
            Assert.Equal(results.First().Id, events[2].Id);
            Assert.Equal(results.Last().Id, events[3].Id);

            results = _repository.GetByOrganizationId(TestConstants.OrganizationId, new PagingOptions().WithLimit(2).WithAfter(String.Concat(events[3].Date.UtcTicks.ToString(), "-", events[3].Id)));
            Assert.Equal(2, results.Count);
            Assert.Equal(results.First().Id, events[4].Id);
            Assert.Equal(results.Last().Id, events[5].Id);

            results = _repository.GetByOrganizationId(TestConstants.OrganizationId, new PagingOptions().WithLimit(2).WithBefore(String.Concat(events[3].Date.UtcTicks.ToString(), "-", events[3].Id)));
            Assert.Equal(2, results.Count);
            Assert.Equal(results.First().Id, events[1].Id);
            Assert.Equal(results.Last().Id, events[2].Id);
        }
        public void Create([FromBody] EventCreateModel createModel)
        {
            var eventEntity = mapper.Map <Event>(createModel);

            eventRepository.Add(eventEntity);
            eventRepository.Commit();

            // schedulerService.Schedule(mapper.Map<EventResource>(createModel));
        }
Example #3
0
        public IActionResult CreateCult(CreateCultViewModel model)
        {
            if (ModelState.IsValid)
            {
                var cult = new Cult(model);
                repository.Add(cult);
                return(RedirectToAction("list", "event"));
            }

            return(View("Create"));
        }
        public void Add_NoRawEvent_DoesNotInsert(string rawEvent)
        {
            var postcrossingEvent = new EventBase
            {
                RawEvent = rawEvent
            };

            var result = _eventRepository.Add(postcrossingEvent);

            Check.That(result).IsNull();
            Check.That(MemoryRepositoryService.GetRepository().Database.GetCollection(PostcrossingTrackerConstants.EventCollectionName).Count()).IsEqualTo(0);
        }
 public ActionResult Create(CreateEventViewModel model)
 {
     if (ModelState.IsValid)
     {
         var newEvent = new Event {
             Id = -1, Name = model.Name, BeginDate = model.BeginTime, EndDate = model.EndTime
         };
         if (IsIntersected(newEvent))
         {
             return(RedirectToAction("Intersection"));
         }
         _db.Add(newEvent);
         return(RedirectToAction("GetAll"));
     }
     return(Json(new { status = "error", errors = GetErrors(ModelState) }, JsonRequestBehavior.DenyGet));
 }
        public IActionResult Add(EventEditViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            viewModel.CurrentEvent.Created = DateTime.Now;

            _eventRepository.Add(viewModel.CurrentEvent);

            var associations = new List <EventAssociation>();
            var date         = DateTime.Now;

            foreach (var team in viewModel.Teams)
            {
                if (team.Selected)
                {
                    associations.Add(new EventAssociation()
                    {
                        Created  = date,
                        Modified = date,
                        TeamId   = team.Id,
                        EventId  = viewModel.CurrentEvent.Id
                    });
                }
            }

            _eventAssociationRepository.AddRange(associations);

            return(RedirectToAction(MethodNames.EVT_ADMINISTRATE));
        }
        public async Task <IActionResult> Create(
            [Bind("Name,Description,Location,StartDate,StartTime,EndDate,EndTime")] Event evt)
        {
            if (!ModelState.IsValid)
            {
                return(View(evt));
            }

            var newEvent = new Event
            {
                Name        = evt.Name,
                Location    = evt.Location,
                Description = evt.Description,
                StartDate   = evt.StartDate,
                StartTime   = evt.StartTime,
                EndDate     = evt.EndDate,
                EndTime     = evt.EndTime,
                OwnerID     = _userManager.GetUserId(User)
            };

            var isAuthorized = await _authorizationService.AuthorizeAsync(
                User, newEvent,
                Operations.Create);

            if (!isAuthorized.Succeeded)
            {
                return(new ChallengeResult());
            }

            _evtRepo.Add(newEvent);
            _evtRepo.Save();
            return(RedirectToAction(nameof(List)));
        }
        public IActionResult Post([FromBody] Event entity)
        {
            try
            {
                if (entity != null)
                {
                    _logger.LogInformation("API Request hit: INSERT Event : " + entity.Name);
                    var result = _eventRepository.Add(entity);

                    if (result == 0)
                    {
                        return(Ok("{\"status\": \"Success\"}"));
                    }
                    else
                    {
                        _logger.LogInformation("API Request (INSERT Event : " + entity.Name + " ) not committed");
                        return(NotFound("Failed: INSERT could not commit"));
                    }
                }
                else
                {
                    _logger.LogInformation("API Request hit (INSERT Event) with null entry");
                    return(BadRequest("Failed: null entry"));
                }
            }

            catch (Exception e)
            {
                _logger.LogError("API Request (INSERT Event) FAILED: ", e);
                return(BadRequest(e));
            }
        }
Example #9
0
        public void Add(EventDto _eventDto)
        {
            var EventObject = EventBuilder.Create()
                              .HasName(_eventDto.Name)
                              .HasDescription(_eventDto.Description)
                              .HasStartDate(_eventDto.StartDate)
                              .HasFinishDate(_eventDto.FinishDate)
                              .Builder();

            EventValidator validateEvent = new EventValidator();

            validateEvent.ValidateAndThrow(EventObject);

            //edit
            if (_eventDto.Id > 0)
            {
                var EventObjectEdit = _eventRepository.SearchForId(_eventDto.Id);
                EventObjectEdit.Name        = _eventDto.Name;
                EventObjectEdit.Description = _eventDto.Description;
                EventObjectEdit.StartDate   = EventObject.StartDate;
                EventObjectEdit.FinishDate  = EventObject.FinishDate;
            }
            //add
            if (_eventDto.Id == 0)
            {
                _eventRepository.Add(EventObject);
            }
        }
Example #10
0
        private async Task <CalendarEvent> SetupNewEventAsync(string name, string description, DateTime startDate, TimeSpan duration)
        {
            var expected = _entityFactory.NewCalendarEvent(name, description, startDate, duration);
            await _repository.Add(expected);

            return((CalendarEvent)expected);
        }
        public async Task <bool> Add(EventInputModel eventInputModel)
        {
            List <EventPhoto> eventPhotos = new List <EventPhoto>();

            if (eventInputModel.Photos != null)
            {
                foreach (var i in eventInputModel.Photos)
                {
                    eventPhotos.Add(new EventPhoto(new Photo(i)));
                }
            }

            List <EventParticipants> eventParticipants = new List <EventParticipants>();

            eventParticipants.Add(new EventParticipants(eventInputModel.personIdCadastro, true));

            var eventId = await _eventRepository.Add(new Event(eventInputModel.Name, eventInputModel.StartDate, eventInputModel.EndDate, eventInputModel.PageProfileLink, eventInputModel.About, eventPhotos, eventParticipants));

            await _addressRepository.Add(new Address(eventInputModel.Address.Longitude,
                                                     eventInputModel.Address.Latitude,
                                                     eventInputModel.Address.Street,
                                                     eventInputModel.Address.Neighborhood,
                                                     eventInputModel.Address.Province,
                                                     eventInputModel.Address.Zip,
                                                     eventInputModel.Address.City,
                                                     eventInputModel.Address.Country,
                                                     eventInputModel.Address.Number,
                                                     personId : null,
                                                     eventId : eventId));

            return(eventId > 0);
        }
Example #12
0
        public async Task <IEnumerable <EventBase> > GetLatestEventsAsync(PostcrossingEventTypeEnum postcrossingEventType = PostcrossingEventTypeEnum.All, long?fromPostcrossingEventId = null)
        {
            await _semaphore.WaitAsync();

            try
            {
                var currentLatestPostcrossingEventId = GetLatestPostcrossingEventId();
                var fromPostcrossingEvent            = fromPostcrossingEventId ?? currentLatestPostcrossingEventId;

                var postcrossingEvents = await _postcrossingClient.GetPostcrossingEventsAsync(fromPostcrossingEvent);

                _currentLatestPostcrossingEventId = _postcrossingEventProcessor.GetLatestEventId(postcrossingEvents, currentLatestPostcrossingEventId);

                if (_postcrossingEngineSettingsService.PersistData)
                {
                    _eventRepository.Add(postcrossingEvents);
                }

                return(_postcrossingEventProcessor.BuildResultForRequestedEventType(postcrossingEventType, fromPostcrossingEvent, postcrossingEvents));
            }
            finally
            {
                _semaphore.Release();
            }
        }
Example #13
0
        public IActionResult Create(EventViewModel objeventDetails) //[Bind("BookId,BookName,Description,ImageUrl,TechnologyId")] Book book)
        {
            if (!objRepository.GetEvents().Any(a => a.EventName == objeventDetails.events.EventName && a.EventDate == objeventDetails.events.EventDate))
            {
                Event objNewEvent = null;
                if (ModelState.IsValid)
                {
                    objNewEvent = new Event
                    {
                        EventName = objeventDetails.events.EventName != null?objeventDetails.events.EventName.Trim() : objeventDetails.events.EventName,
                                        EventDescription = objeventDetails.events.EventDescription != null?objeventDetails.events.EventDescription.Trim() : objeventDetails.events.EventDescription,
                                                               CreatedBy   = User.FindFirstValue(ClaimTypes.NameIdentifier),
                                                               CreatedDate = DateTime.Now,
                    };

                    objRepository.Add(objNewEvent);
                    return(RedirectToAction(nameof(Index)));
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Event already exists.");
            }

            return(View());
        }
Example #14
0
        public IActionResult Post([FromBody] EventDto postedEvent)
        {
            if (postedEvent == null)
            {
                ModelState.AddModelError("Event", "Check all required fields");
                return(BadRequest(ModelState));
            }

            if (postedEvent.TypeId == 0)
            {
                ModelState.AddModelError("EventType", "You must provide the TypeId");
                return(BadRequest(ModelState));
            }

            var eventType = _eventTypeRepository.GetOne(postedEvent.TypeId);

            if (eventType.IsCompleted && eventType.Result == null)
            {
                ModelState.AddModelError("EventType", "The Event Type provided does not exists");
                return(BadRequest(ModelState));
            }

            var newEvent = new Event(postedEvent.Description, postedEvent.Summary, postedEvent.Date, eventType.Result)
            {
                Price = postedEvent.Price, ImageLink = postedEvent.ImageLink
            };

            _eventRepository.Add(newEvent);
            _eventRepository.SaveChanges();

            return(CreatedAtRoute("GetEvent", new { id = newEvent.Id }, Mapper.Map <Event, EventDto>(newEvent)));
        }
Example #15
0
        public void Add(List <Event> events)
        {
            foreach (Event parsedEvent in events)
            {
                string eventFromLogKey = parsedEvent.EventKey;
                Event  existingEvent   = _eventRepository.GetEvent(eventFromLogKey);

                if (existingEvent == null)
                {
                    _eventRepository.Add(parsedEvent);
                }
                else
                {
                    DateTime newEventCreationDate = parsedEvent.CreationDate;
                    DateTime eventCreationDate    = existingEvent.CreationDate;

                    bool isParsedNewer = newEventCreationDate.CompareTo(eventCreationDate) > 0;

                    if (isParsedNewer)
                    {
                        _eventRepository.Update(parsedEvent);
                    }
                }
            }
        }
        //GET api/events/create
        public IHttpActionResult Create(EventDto eventDto)
        {
            string validationMessage = eventDto.validateForCreation();

            if (!String.IsNullOrEmpty(validationMessage))
            {
                return(BadRequest(validationMessage));
            }
            User user = _userRepo.Single(x => x.UserName.Equals(eventDto.UserName));

            if (user == null)
            {
                return(BadRequest("navedeni korisnik ne postoji"));
            }
            City city = _userRepo.FindCity(eventDto.CityName);

            if (city == null)
            {
                return(BadRequest("navedeni grad ne postoji"));
            }
            Event ev = EventMapper.MapEventDtoToEvent(eventDto);

            ev.Creator = user;
            ev.City    = city;
            ev.Creator = user;
            ev.Sport   = new Sport()
            {
                Id = eventDto.SportId
            };

            _eventRepo.Add(ev);
            return(Ok());
        }
Example #17
0
        public void AddVotingEvent(CongressVoting voting, VotingStatusEnum votingStatus)
        {
            var countryEvent = new CountryVotingGameEvent(voting, votingStatus, GameTime.Now);

            eventRepository.Add(countryEvent.CreateEntity());
            ConditionalSaveChanges(eventRepository);
        }
        public Task <bool> Handle(CreateEventCommand request, CancellationToken cancellationToken)
        {
            var _event = new Event()
            {
                Name              = request.Name,
                Price             = request.Price,
                Description       = request.Description,
                EventDate         = request.EventDate,
                LastBookingDate   = request.LastBookingDate,
                EndEventDate      = request.EndEventDate,
                MinCustomerAmount = request.MinCustomerAmount,
                MaxCustomerLimit  = request.MaxCustomerLimit,
                PayOnline         = request.PayOnline,
                Address           = request.Address,
                Image             = request.Image,
                Food              = request.Food,
                Attendance        = new Attendance(),
                Region            = request.Region,
                City              = request.City,
                Marker            = request.Marker,
                Store             = request.Store
            };

            _eventRepository.Add(_event);
            _unitOfWork.Commit();

            return(Task.FromResult(true));
        }
Example #19
0
        public async Task <IActionResult> AddEvent(EventToAddDTO eventToAdd)
        {
            var eventDB = await _repo.Add(eventToAdd);

            var eventToReturn = _mapper.Map <EventToReturnDTO>(eventDB);

            return(Ok(eventToReturn));
        }
Example #20
0
        public void AddEvent(Battle battle, BattleStatusEnum battleStatus)
        {
            Debug.Assert(battle.ID > 0);
            var e = new BattleGameEvent(battle, battleStatus, GameTime.Now);

            eventRepository.Add(e.CreateEntity());
            ConditionalSaveChanges(eventRepository);
        }
Example #21
0
        public void AddEvent(War war, WarStatusEnum warStatus)
        {
            Debug.Assert(war.ID > 0);
            var e = new WarGameEvent(war, warStatus, GameTime.Now);

            eventRepository.Add(e.CreateEntity());
            ConditionalSaveChanges(eventRepository);
        }
        public Task ExecuteAsync(CreateEventCommand message)
        {
            var @event = _eventFactory.Create(message.Event);

            _eventRepository.Add(@event);

            _createRouteCommandHandler.ExecuteAsync(new CreateRouteCommand(message.Route));
            return(Task.CompletedTask);
        }
Example #23
0
 public override void Process(EventContext ctx)
 {
     try {
         ctx.Event = _eventRepository.Add(ctx.Event);
     } catch (DuplicateDocumentException ex) {
         Log.Info().Project(ctx.Event.ProjectId).Message("Ignoring duplicate error submission: {0}", ctx.Event.Id).Write();
         ctx.IsCancelled = true;
     }
 }
Example #24
0
        public void Add(Event newEvent)
        {
            if (newEvent == null)
            {
                throw new ArgumentNullException(nameof(newEvent));
            }

            _eventRepository.Add(newEvent);
        }
Example #25
0
        // Post: api/Events
        public IHttpActionResult Post(Event ev)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var createdEventAtRoute = _eventRepository.Add(ev);

            return(CreatedAtRoute("DefaultApi", new { controller = "Events", id = ev.Id }, createdEventAtRoute));
        }
Example #26
0
        private async Task HandleMessage(MqttApplicationMessageReceivedEventArgs eventArgs)
        {
            Log.Information($"[Received message]:");
            Log.Information($"[Topic]: {eventArgs.ApplicationMessage.Topic}");
            Log.Information($"[Payload]: {eventArgs.ApplicationMessage.ConvertPayloadToString()}");

            string text = Encoding.UTF8.GetString(eventArgs.ApplicationMessage.Payload);

            _eventRepository.Add(text);
        }
Example #27
0
 public async Task CreateEvent(EventType eventType, string eventDescription)
 {
     var systemEvent = new Event
     {
         DateCreated      = DateTime.Now,
         EventType        = eventType,
         EventDescription = eventDescription
     };
     await _repository.Add(systemEvent);
 }
 // POST api/values
 public IHttpActionResult Post([FromBody] EventShared result)
 {
     _eventRepository.Add(new Event
     {
         EventType = (EventType)result.EventType,
         Location  = CreatePoint(result.Latitude.GetValueOrDefault(), result.Longitude.GetValueOrDefault()),
         Date      = result.Date
     });
     return(Ok());
 }
Example #29
0
        public async Task <IActionResult> EventRegister(EventUser eventmodel)
        {
            if (ModelState.IsValid)
            {
                await userrepo.Add(eventmodel);

                return(RedirectToRoute("EventList"));
            }
            return(View());
        }
Example #30
0
        public async Task <IActionResult> Create(EventData model)
        {
            if (ModelState.IsValid)
            {
                await repo.Add(model);

                return(RedirectToRoute("EventList"));
            }
            return(View());
        }
Example #31
0
        private void ResumeSecondBackOff(
            Event secondEventInstance,
            IUnitOfWork unitOfWork,
            IJobRepository jobRepository,
            IEventRepository eventRepository,
            IDeliveryGroupRepository deliveryGroupRepository,
            Event currentEvent = null
            )
        {
            var eventDetail = secondEventInstance.EventActions.FirstOrDefault(ed => ed.Action == EventAction.Actions.MTAPause);

            if (eventDetail != null && !_mtaAgent.IsQueueActive(eventDetail.Pmta.ToMta(), eventDetail.PmtaQueue))
            {
                _logger.InfoFormat("Resuming {0} on {1}", eventDetail.PmtaQueue, eventDetail.Pmta.Host);

                Event dbLogEvent = currentEvent ?? eventRepository.Add(new Event()
                                                       {
                                                           EventName = Event.EventNames.SecondBackOffResume,
                                                           Monitor = Event.Monitors.Four21,
                                                           SeriesId = secondEventInstance.SeriesId
                                                       });

                _mtaAgent.Purge(eventDetail.Pmta.ToMta(), eventDetail.PmtaQueue);
                _logger.InfoFormat("Purged {0} on {1}", eventDetail.PmtaQueue, eventDetail.Pmta.Host);

                dbLogEvent.EventActions.Add(new EventAction()
                        {
                            Action = EventAction.Actions.MTAPurge,
                            Pmta = eventDetail.Pmta,
                            PmtaQueue = eventDetail.PmtaQueue
                        });

                _mtaAgent.UnPause(eventDetail.Pmta.ToMta(), eventDetail.PmtaQueue);
                _logger.InfoFormat("Resumed {0} on {1}", eventDetail.PmtaQueue, eventDetail.Pmta.Host);

                dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.ResumedQueue,
                    Pmta = eventDetail.Pmta,
                    PmtaQueue = eventDetail.PmtaQueue
                });

                lock (_locker)
                {
                    unitOfWork.SaveChanges();
                }
            }
        }
Example #32
0
        private void ProcessSecondBackOff(
            Pmta pmta,
            string queue,
            Event lastEvent,
            IUnitOfWork unitOfWork,
            IEventRepository eventRepository
            )
        {
            _logger.InfoFormat("Second Back Off for {0} on {1}", queue, pmta.Host);

            Event dbLogEvent = eventRepository.Add(new Event()
                                                   {
                                                       EventName = Event.EventNames.SecondBackOff,
                                                       Monitor = Event.Monitors.Four21,
                                                       SeriesId = lastEvent.SeriesId
                                                   });

            _mtaAgent.Pause(pmta.ToMta(), queue);
            _logger.InfoFormat("Paused {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.MTAPause,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.RemoveBackOff,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.Purge(pmta.ToMta(), queue);
            _logger.InfoFormat("Purged {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
            {
                Action = EventAction.Actions.MTAPurge,
                Pmta = pmta,
                PmtaQueue = queue
            });

            lock (_locker)
            {
                unitOfWork.SaveChanges();
            }
        }
Example #33
0
        private void ProcessFourthBackOff(
            Pmta pmta,
            string queue,
            Event lastEvent,
            DateTime nextReset,
            IUnitOfWork unitOfWork,
            IJobRepository jobRepository,
            IEventRepository eventRepository,
            IDeliveryGroupRepository deliveryGroupRepository
            )
        {
            _logger.InfoFormat("Fourth Back Off for {0} on {1}", queue, pmta.Host);

            var dbLogEvent = eventRepository.Add(new Event()
            {
                EventName = Event.EventNames.FourthBackOff,
                Monitor = Event.Monitors.Four21,
                SeriesId = lastEvent.SeriesId
            });

            _mtaAgent.Pause(pmta.ToMta(), queue);
            _logger.InfoFormat("Paused {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.MTAPause,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                {
                    Action = EventAction.Actions.RemoveBackOff,
                    Pmta = pmta,
                    PmtaQueue = queue
                });

            _mtaAgent.Purge(pmta.ToMta(), queue);
            _logger.InfoFormat("Purged {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
            {
                Action = EventAction.Actions.MTAPurge,
                Pmta = pmta,
                PmtaQueue = queue
            });

            lock (_locker)
            {
                var deliveryGroup = DeliveryGroup.GetByVmta(pmta, queue, deliveryGroupRepository);

                if (deliveryGroup != null)
                {
                    DeliveryGroup.CancelHotmailJobsByDeliveryGroup(jobRepository, _logger, deliveryGroup, nextReset, dbLogEvent);
                }

                unitOfWork.SaveChanges();
            }

            _emailNotification.SendEvent(dbLogEvent);

        }
Example #34
0
        private void ProcessFirstBackOff(
            Pmta pmta,
            string queue,
            IUnitOfWork unitOfWork,
            IEventRepository eventRepository
            )
        {
            _logger.InfoFormat("First Back Off for {0} on {1}", queue, pmta.Host);

            Event dbLogEvent = eventRepository.Add(new Event()
                                                   {
                                                       EventName = Event.EventNames.FirstBackOff,
                                                       Monitor = Event.Monitors.Four21,
                                                       SeriesId = Guid.NewGuid()
                                                   });

            _mtaAgent.RemoveBackoff(pmta.ToMta(), queue);
            _logger.InfoFormat("Removed Back Off from {0} on {1}", queue, pmta.Host);

            dbLogEvent.EventActions.Add(new EventAction()
                                            {
                                                Action = EventAction.Actions.RemoveBackOff,
                                                Pmta = pmta,
                                                PmtaQueue = queue
                                            });

            lock (_locker)
            {
                unitOfWork.SaveChanges();
            }
        }