예제 #1
0
 public async System.Threading.Tasks.Task <OperationResult <Event> > GetEvents(int pageSize, int pageNumber, bool descending)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Event> >(() =>
     {
         OperationResult <Event> result = new OperationResult <Event>();
         try
         {
             if (IsInCompany())
             {
                 result.Count = EventsRepository.Count("CompanyId = @CompanyId", new { CompanyId = CurrentUser.CompanyId.Value });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = EventsRepository.Search("CompanyId = @CompanyId",
                                                                     new { PageSize = pageSize, PageNumber = pageNumber, CompanyId = CurrentUser.CompanyId.Value }, descending);
                 }
                 result.Result = true;
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
예제 #2
0
 public async System.Threading.Tasks.Task <OperationResult <Event> > CreateEvent(Event ev)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Event> >(() =>
     {
         OperationResult <Event> result = new OperationResult <Event>();
         try
         {
             if (IsInCompany())
             {
                 ev.CompanyId = CurrentUser.CompanyId.Value;
                 Event newEvent = EventsRepository.CreateOrUpdate(ev);
                 if (newEvent.Id > 0)
                 {
                     result.SingleResult = newEvent;
                     result.Result = true;
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
예제 #3
0
        // POST api/student
        public HttpResponseMessage Post(events Event)
        {
            string msg = "";

            if (Event.eventDate > Event.checkIn)
            {
                msg = "Check In: " + Event.checkIn.ToShortDateString() + " before event Date: " + Event.eventDate.ToShortDateString() + "?";
            }
            else if (Event.checkOut > Event.eventDate)
            {
                msg = "Check Out: " + Event.checkOut.ToShortDateString() + " after event Date: " + Event.eventDate.ToShortDateString() + "?";
            }

            if (msg.Length > 0)
            {
                var    response = Request.CreateResponse(HttpStatusCode.InternalServerError, msg);
                string url      = Url.Link("DefaultApi", new { msg });
                response.Headers.Location = new Uri(url);
                return(response);
            }
            else
            {
                EventsRepository.InsertEvent(ref Event);
                var    response = Request.CreateResponse(HttpStatusCode.Created, Event);
                string url      = Url.Link("DefaultApi", new { Event.id });
                response.Headers.Location = new Uri(url);
                return(response);
            }
        }
예제 #4
0
 protected BaseCommand(
     ChatMessage commandMessage,
     EventsRepository eventsRepository)
 {
     Message = commandMessage;
     EventsRepository = eventsRepository;
 }
예제 #5
0
 private IScoreMethod ScoreMethodInstance(int evt)
 {
     string sClassName = "ScoreMethod";
     string sAssemblyName = "";
     try
     {
         EventsRepository oevtrep = new EventsRepository();
         lsevent oevt = oevtrep.GetByID(evt);
         ScoreMethodRepository ismrep = new ScoreMethodRepository();
         score_method osm = ismrep.GetByID(oevt.score_method_id);
         sAssemblyName = osm.proc;
         Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
         sAssemblyName = osm.proc + "." + sClassName;
         IScoreMethod inst = (IScoreMethod)asmCurrent.CreateInstance(sAssemblyName);
         if (inst == null)
         {
             throw new Exception("Could not create an instance of class " + sClassName);
         }
         return inst;
     }
     catch (Exception ex)
     {
         sAssemblyName = "LaserSportDataAPI.ScoreMethod.Sample";
         sClassName = sAssemblyName + ".ScoreMethod";
         Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
         IScoreMethod inst = (IScoreMethod)asmCurrent.CreateInstance(sClassName);
         return inst;
         //return null;
     }
 }
        public async Task AndThereAreUnprocessedPeriodsThenThePeriodsAreReturned()
        {
            var lastEventId     = "123";
            var returnedPeriods = new List <PeriodEnd>
            {
                new PeriodEnd {
                    Id = "sdfkujf"
                },
                new PeriodEnd {
                    Id = lastEventId
                },
                new PeriodEnd {
                    Id = "dlfkbmbg"
                },
                new PeriodEnd {
                    Id = "cdvflkbc"
                }
            };

            var expectedPeriods = returnedPeriods.SkipWhile(x => x.Id != lastEventId.ToString()).Skip(1);

            EventsRepository.Setup(x => x.GetLastProcessedEventId <string>(_paymentEventFeedName)).ReturnsAsync(lastEventId);
            EventsApi.Setup(x => x.GetPeriodEnds()).ReturnsAsync(returnedPeriods.ToArray());

            var response = await Service.GetUnprocessedPeriodEnds <Payment>();

            response.ShouldBeEquivalentTo(expectedPeriods);
        }
예제 #7
0
    private void UpdateEvent(EventEntity eventEntity)
    {
        DataAccess dataAccess = new DataAccess(DataAccess.GetWebConfigConnectionString("Infoskærm"));

        try {
            dataAccess.Open();

            EventsRepository eventRepository = new EventsRepository();

            bool result = eventRepository.Update(dataAccess, eventEntity);
            eventRepository.DeleteEventRooms(dataAccess, eventEntity.Id);
            eventRepository.InsertEventRooms(dataAccess, GetSelectedRooms(), eventEntity.Id);
            dataAccess.StartTransaction();
            dataAccess.Commit();

            if (result == true)
            {
                RegisterSweetAlertScriptOnSuccess();
            }
        } catch (Exception exc) {
            System.Diagnostics.Debug.WriteLine(exc);
            dataAccess.Rollback();
        } finally {
            dataAccess.Close();
        }
        // Halt the thread for half a seconds, so we can show the sweetalert message.
        System.Threading.Thread.Sleep(500);
    }
예제 #8
0
        public async Task GetRemoteDoesNotError()
        {
            // In-memory database only exists while the connection is open
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var options = new DbContextOptionsBuilder <LuxMeetContext>()
                          .UseSqlite(connection)
                          .Options;

            // Create the schema in the database
            using (var context = new LuxMeetContext(options))
            {
                context.Database.EnsureCreated();

                EventsRepository       rep    = new EventsRepository(connection);
                LuxMeet.DbModels.Event _event = await rep.GetRemote();

                var config = new MapperConfiguration(cfg => cfg.CreateMap <LuxMeet.DbModels.Event, LuxMeet.ViewModels.Event>());
                config.AssertConfigurationIsValid();

                // Perform mapping
                var   mapper = config.CreateMapper();
                Event dto    = mapper.Map <LuxMeet.DbModels.Event, LuxMeet.ViewModels.Event>(_event);

                dto.name.ShouldBe("new very future event");
                dto.location.ShouldBe("Route d'Esch");
            }
        }
    private void AddCloneEvent(EventEntity eventEntity)
    {
        DataAccess dataAccess = new DataAccess(DataAccess.GetWebConfigConnectionString("Infoskærm"));

        try {
            dataAccess.Open();

            EventsRepository eventRepository = new EventsRepository();

            bool result = eventRepository.Insert(dataAccess, eventEntity);
            //Add all rooms
            eventRepository.InsertEventRooms(dataAccess, GetSelectedRooms(), (int)eventRepository.LastInsertedId);
            dataAccess.StartTransaction();
            dataAccess.Commit();

            if (result == true)
            {
                RegisterSweetAlertScriptOnSuccess();
            }
        } catch (Exception) {
            dataAccess.Rollback();
        } finally {
            dataAccess.Close();
        }
        // Halt the thread for half a seconds, so we can show the sweetalert message.
        System.Threading.Thread.Sleep(500);
    }
예제 #10
0
        public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            string sEventId = "";
            int EventId = int.MinValue;
            EventsRepository evtRepo = new EventsRepository();

            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized);
            }
            else
            {
                string authToken = actionContext.Request.Headers.Authorization.Parameter;
                string decodedToken = Encoding.UTF8.GetString(Convert.FromBase64String(authToken));

                string username = decodedToken.Substring(0, decodedToken.IndexOf(":"));
                string password = decodedToken.Substring(decodedToken.IndexOf(":") + 1);
                IEnumerable<string> headerValues;

                if (actionContext.Request.Headers.TryGetValues("event_id", out headerValues))
                {
                    sEventId = headerValues.First();
                    int.TryParse(sEventId, out EventId);
                }
                if (!evtRepo.PlayerIsAuthorizedToEdit(EventId, username, password))
                {
                    actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Unauthorized);
                }

            }
        }
예제 #11
0
 public UsersController(EventsRepository eventsRepository, UsersInfoRepository usersInfoRepository, UserManager <IdentityUser> usersManager, WalletsRepository walletsRepository, UserRepository userRepository)
 {
     _eventsRepository    = eventsRepository;
     _usersInfoRepository = usersInfoRepository;
     _usersManager        = usersManager;
     _walletsRepository   = walletsRepository;
     _userRepository      = userRepository;
 }
예제 #12
0
 public UnitOfWork()
 {
     _context = new ModelContainer();
     Media    = new MediaRepository(_context);
     Persons  = new PersonsRepository(_context);
     Events   = new EventsRepository(_context);
     Tags     = new TagsRepository(_context);
 }
예제 #13
0
        public override string Execute()
        {
            var participantsGroup = MessageParser.GetParticipantsGroupFromMessage(Message);

            participantsGroup.IsSure = false;
            EventsRepository.AddParticipantsGroupToEvent(Message.ChatName, participantsGroup);
            return(base.Execute());
        }
 public void Init(EventsRepository evRep,
                  TeamsRepository teamsRepository,
                  int id)
 {
     Tr    = teamsRepository;
     Event = evRep.Get(id);
     Teams = Event.Teams;
 }
예제 #15
0
 /// <summary>
 /// Initializes the view model.
 /// </summary>
 public virtual void Init(Repository repository,
                          EventsRepository eventsRepository,
                          TeamMembersRepository tmr)
 {
     EventSelectListItems = new SelectList(
         eventsRepository.GetList(),
         "Id", "Title");
 }
예제 #16
0
        private async void LoadEventsCommandExecute()
        {
            var events = await EventsRepository.GetUpcomingEvents();

            //TODO: Check if we recieved data, possibly update UI to alert if it is offline/cached or live

            Events = events.Data.ToList();
        }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int?eventId = null;
            try {
                eventId = int.Parse(Request.QueryString.Get("eventId"));
            } catch (Exception exc) {
                Response.Redirect("Search.aspx");
            }

            DataAccess dataAccess = new DataAccess(DataAccess.GetWebConfigConnectionString("Infoskærm"));
            try {
                dataAccess.Open();
                EventsRepository eventRepository = new EventsRepository();

                eventEntity = eventRepository.FetchById(dataAccess, (int)eventId);

                startDate.SelectedDate = eventEntity.FromDate.Date;
                startDate.VisibleDate  = startDate.SelectedDate;

                if (eventEntity.IsCanceled == true)
                {
                    canceled.Visible = true;
                }
                else
                {
                    canceled.Visible = false;
                }

                // Fetch all departments and populate dep. select menu
                PopulateDepartmentsSelect(dataAccess, eventRepository);

                // Fetch all rooms which are corresponding to the chosen department and populate rooms select menu
                int departmentId = int.Parse(departmentsSelect.Items[departmentsSelect.SelectedIndex].Value);
                PopulateRoomsSelect(dataAccess, eventRepository, departmentId);
                SelectRooms(eventEntity.Rooms);
            } catch (Exception) {
            } finally {
                dataAccess.Close();
            }
        }
        else
        {
            eventEntity = CreateEventEntityFromForm();

            List <int> rooms = GetSelectedRooms();

            dataAccess.Open();
            PopulateRoomsSelect(dataAccess, eventRepository, int.Parse(departmentsSelect.Items[departmentsSelect.SelectedIndex].Value));
            dataAccess.Close();

            SelectRooms(rooms);
        }

        DataBind();
    }
예제 #18
0
        public HttpResponseMessage Get(int id)
        {
            //Not able to get one record for delete.
            //Could setup a delete controller or add method to string?
            EventsRepository.DeleteEvent(id);
            var response = Request.CreateResponse(HttpStatusCode.OK, id);

            return(response);
        }
예제 #19
0
 public EventsRepositoryFacts()
 {
     _serializer = new Mock<IEventsSerializer>();
     _eventsRepository = new EventsRepository(_serializer.Object);
     _serializer.Setup(s => s.Deserialize())
         .Returns(
             new EventsList(
                 new List<Event> { new Event(new DateTime(2012, 1, 1)), new Event(new DateTime(2012, 1, 2)) }));
 }
예제 #20
0
 public WalletsController(WalletsRepository walletsRepository,
                          TransactionManager transactionManager,
                          EventsRepository eventsRepository,
                          WalletService walletService)
 {
     _walletsRepository  = walletsRepository;
     _transactionManager = transactionManager;
     _eventsRepository   = eventsRepository;
     _walletService      = walletService;
 }
예제 #21
0
        // DELETE api/student/5
        public HttpResponseMessage Delete(int id)
        {
            //EventsAccess A = new EventsAccess();
            //A.DeleteEvent(id);
            //new EventsAccess().DeleteEvent(id);
            EventsRepository.DeleteEvent(id);
            var response = Request.CreateResponse(HttpStatusCode.OK, id);

            return(response);
        }
예제 #22
0
        public ActionResult GetRecords(string CurrentView, DateTime?CurrentDate, string CurrentAction)
        {
            db.Configuration.ProxyCreationEnabled = false;
            var             data   = EventsRepository.FilterAppointment(System.Convert.ToDateTime(CurrentDate), CurrentAction, CurrentView);
            BatchDataResult result = new BatchDataResult();

            result.result = data;
            result.count  = EventsRepository.GetAllRecords().ToList().Count;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
        public void EventsRepository_EmptyConnectionString_ExceptionWhenQuery()
        {
            var repo = new EventsRepository("");

            Assert.ThrowsAsync <AggregateException>(async() => await repo.GetEventById(1));
            Assert.ThrowsAsync <AggregateException>(async() => await repo.GetEventsBySportAndDate(1, DateTime.Now));

            var eventMock = new Mock <SportEvent>();

            Assert.ThrowsAsync <AggregateException>(async() => await repo.UpdateEvent(eventMock.Object));
        }
    private void PopulateRoomsSelect(DataAccess dataAccess, EventsRepository repository, int departmentId)
    {
        List <RoomEntity> rooms = repository.FetchDepartmentRooms(dataAccess, departmentId);

        // Empty the select
        roomsSelect.Items.Clear();
        foreach (RoomEntity room in rooms)
        {
            roomsSelect.Items.Add(new ListItem(room.Identifier, room.Id.ToString()));
        }
    }
예제 #25
0
    private void PopulateDepartmentsSelect(DataAccess dataAccess, EventsRepository repository)
    {
        List <DepartmentEntity> departments = repository.FetchAllDepartments(dataAccess);

        foreach (DepartmentEntity department in departments)
        {
            departmentsSelect.Items.Add(new ListItem(department.Name, department.Id.ToString()));
        }
        // Find and select event's department.
        departmentsSelect.Items.FindByValue(eventEntity.Rooms[0].DepartmentId.ToString()).Selected = true;
    }
예제 #26
0
        public void should_store_and_retrieve_event()
        {
            // Arrange
            var serializer = new EventsSerializer("test.xml");
            var repository = new EventsRepository(serializer);
            var dt = new DateTime(2012, 7, 14);

            // Act
            repository.Add(new Event(dt));
            var list = repository.GetAll();

            // Assert
            Assert.Equal(1, list.Count);
            Assert.Equal(dt, list[0].Date);
        }
예제 #27
0
        private IScoreMethod ScoreMethodInstance(int evt)
        {
            string sClassName = "ScoreMethod";
            string sAssemblyName = "";
            string sObjectName = "";
            IScoreMethod inst;
            try
            {
                //get the full location of the assembly with DaoTests in it
                EventsRepository oevtrep = new EventsRepository();
                lsevent oevt = oevtrep.GetByID(evt);
                ScoreMethodRepository ismrep = new ScoreMethodRepository();
                score_method osm = ismrep.GetByID(oevt.score_method_id);
                sAssemblyName = osm.proc;
                if (String.IsNullOrEmpty(sAssemblyName)) {
                    sAssemblyName = "LaserSportDataAPI.SystemObjects.Sample";
                }
                string AssemblyFilePath = AssemblyDirectory + "\\" + sAssemblyName + ".dll";

                Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
                sObjectName = osm.proc + "." + sClassName;
                inst = (IScoreMethod)asmCurrent.CreateInstance(sObjectName);
                if (inst==null) {
                    throw new Exception("Could not create an instance of class " + sObjectName);
                }
                return inst;
            }
            catch (Exception ex)
            {
                sAssemblyName = "LaserSportDataAPI.SystemObjects.Sample";
                sObjectName = sAssemblyName + "." + sClassName;
                Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
                inst = (IScoreMethod)asmCurrent.CreateInstance(sObjectName);
                return inst;
                //return null;
            }
        }
예제 #28
0
 protected void InitDataObjects()
 {
     eventsRepo = new EventsRepository();
     scoreMethodRepo = new ScoreMethodRepository();
     seriesRepo = new SeriesRepository();
     teamsRepo = new TeamsRepository();
     eventTeamsRepo = new EventTeamsRepository();
     playersRepo = new PlayersRepository();
     eventPlayersRepo = new EventPlayersRepository();
     matchRepo = new MatchesRepository();
     matchTeamsRepo = new MatchTeamsRepository();
     packsetRepo = new PacksetsRepository();
     matchPlayerRepo = new MatchPlayersRepository();
 }
예제 #29
0
        public void Setup()
        {
            _repository = new Repository<EntityEventSource<Ship, ObjectId>, ObjectId>("RationalEvs", "EventSourcing");
            _queryBuilder = new MongoQuerySnapshotBuilder<Ship, ObjectId>();
            _eventsRepository = new EventsRepository<Ship, ObjectId>(_repository, _queryBuilder, 0);

            _fsmConfigurator = FsmConfiguratorFactory.WithXgml("shipStateMachine.xgml").SetInitialState("In Navigation").WithDomainAssembly
            <DepartureEvent>("RationalEvs.Test.DomainFake.Events").
            Create();

            _aggregateFactory = new AggregateRootFactory<Ship, ObjectId>(_eventsRepository, _fsmConfigurator)
                                    {
                                        Logger = LogManager.GetLogger(GetType())
                                    };

            _ship = new Ship { Id = ObjectId.GenerateNewId() };
        }
예제 #30
0
        public TasklingClient(IConfigurationReader configurationReader,
            ITaskRepository taskRepository = null,
            ITasklingConfiguration configuration = null,
            ITaskExecutionRepository taskExecutionRepository = null,
            IExecutionTokenRepository executionTokenRepository = null,
            ICommonTokenRepository commonTokenRepository = null,
            IEventsRepository eventsRepository = null,
            ICriticalSectionRepository criticalSectionRepository = null,
            IBlockFactory blockFactory = null,
            IBlockRepository blockRepository = null,
            IRangeBlockRepository rangeBlockRepository = null,
            IListBlockRepository listBlockRepository = null,
            IObjectBlockRepository objectBlockRepository = null,
            ICleanUpService cleanUpService = null,
            ICleanUpRepository cleanUpRepository = null)
        {
            if (taskRepository == null)
                taskRepository = new TaskRepository();

            if (configuration == null)
                _configuration = new TasklingConfiguration(configurationReader);

            if (commonTokenRepository == null)
                commonTokenRepository = new CommonTokenRepository();

            if (executionTokenRepository == null)
                executionTokenRepository = new ExecutionTokenRepository(commonTokenRepository);

            if (eventsRepository == null)
                eventsRepository = new EventsRepository();

            if (taskExecutionRepository != null)
                _taskExecutionRepository = taskExecutionRepository;
            else
                _taskExecutionRepository = new TaskExecutionRepository(taskRepository, executionTokenRepository, eventsRepository);

            if (criticalSectionRepository != null)
                _criticalSectionRepository = criticalSectionRepository;
            else
                _criticalSectionRepository = new CriticalSectionRepository(taskRepository, commonTokenRepository);

            if (blockRepository == null)
                blockRepository = new BlockRepository(taskRepository);

            if (rangeBlockRepository != null)
                _rangeBlockRepository = rangeBlockRepository;
            else
                _rangeBlockRepository = new RangeBlockRepository(taskRepository);

            if (listBlockRepository != null)
                _listBlockRepository = listBlockRepository;
            else
                _listBlockRepository = new ListBlockRepository(taskRepository);

            if (objectBlockRepository != null)
                _objectBlockRepository = objectBlockRepository;
            else
                _objectBlockRepository = new ObjectBlockRepository(taskRepository);

            if (blockFactory != null)
                _blockFactory = blockFactory;
            else
                _blockFactory = new BlockFactory(blockRepository, _rangeBlockRepository, _listBlockRepository, _objectBlockRepository, _taskExecutionRepository);

            if (cleanUpRepository == null)
                cleanUpRepository = new CleanUpRepository(taskRepository);

            if (cleanUpService != null)
                _cleanUpService = cleanUpService;
            else
                _cleanUpService = new CleanUpService(_configuration, cleanUpRepository);
        }