Beispiel #1
0
        public async Task Update(int id, OnlineEvent onlineEvent)
        {
            var parameters = CreateDynamicOnlineEventForUpdate(id, onlineEvent);

            await _sqlDataAccess.ExecuteStoredProcedureAsync(StoredProcedures.SpOnlineEventUpdate, _dbConnectionString,
                                                             parameters);
        }
Beispiel #2
0
 private static void AddOnlineEventProperties(DynamicParameters parameters, OnlineEvent onlineEvent)
 {
     parameters.Add("@Name", onlineEvent.Name);
     parameters.Add("@Description", onlineEvent.Description);
     parameters.Add("@StartDate", onlineEvent.StartDate);
     parameters.Add("@Organizer", onlineEvent.Organizer);
     parameters.Add("@ImageContent", onlineEvent.ImageContent);
 }
Beispiel #3
0
        private static DynamicParameters CreateDynamicOnlineEventForUpdate(int id, OnlineEvent onlineEvent)
        {
            var parameters = new DynamicParameters();

            parameters.Add("@Id", id);
            AddOnlineEventProperties(parameters, onlineEvent);

            return(parameters);
        }
Beispiel #4
0
        private static DynamicParameters CreateDynamicOnlineEventForInsert(OnlineEvent onlineEvent)
        {
            var parameters = new DynamicParameters();

            parameters.Add("@Id", 0, DbType.Int32, ParameterDirection.Output);
            AddOnlineEventProperties(parameters, onlineEvent);

            return(parameters);
        }
 public int[] AddEvent(OnlineEvent ev)
 {
     int[] result = null;
     if (Position < Text.Length && Text[Position] == ev.Value)
     {
         result = new int[] { Position };
         Position++;
     }
     return(result);
 }
Beispiel #6
0
        public ShadowDevice Apply(OnlineEvent onlineEvent)
        {
            var eventHistory = onlineEvent.ToEventHistory();

            this.IsOnline = true;
            this.AddEventHistory(eventHistory);

            Console.WriteLine($"{onlineEvent.DeviceId} is online at {onlineEvent.EventTime}");

            return(this);
        }
Beispiel #7
0
        public async Task <CreatedRow> Insert(OnlineEvent onlineEvent)
        {
            var parameters = CreateDynamicOnlineEventForInsert(onlineEvent);

            await _sqlDataAccess.ExecuteStoredProcedureAsync(StoredProcedures.SpOnlineEventInsert, _dbConnectionString,
                                                             parameters);

            return(new CreatedRow
            {
                Id = parameters.Get <int>("@Id")
            });
        }
Beispiel #8
0
        public async Task <IActionResult> Put([FromRoute] int id, OnlineEvent onlineEvent)
        {
            var row = await _onlineEventData.Get(id);

            if (row.ToString() == "[]")
            {
                return(NotFound());
            }

            await _onlineEventData.Update(id, onlineEvent);

            return(NoContent());
        }
Beispiel #9
0
        public async Task <IActionResult> OnGet(int id)
        {
            try
            {
                OnlineEvent = await _httpHelper.GetAsync <OnlineEvent>(BandCamsEndpoints.GetOnlineEvent(id));

                return(Page());
            }
            catch (Exception)//TODO porządna obsługa - słabe rozwiązanie bo każdy wyjątek kalsyfikujemy jakby api zwróciło 404
            {
                return(NotFound());
            }
        }
        public async Task PutReturns400ResponseTest()
        {
            // arrange
            var expected    = HttpStatusCode.BadRequest;
            var client      = GetFactory().CreateClient();
            var onlineEvent = new OnlineEvent();

            // act
            var actual = await client.PutAsJsonAsync("/api/OnlineEvent/1", onlineEvent);

            // assert
            Assert.True(actual.StatusCode == expected, $"{actual.StatusCode} was returned instead of {expected}");
        }
        public async Task PutReturns404ResponseTest()
        {
            // arrange
            var expected    = HttpStatusCode.NotFound;
            var client      = GetFactory().CreateClient();
            var onlineEvent = new OnlineEvent
            {
                Name         = "integrationTestName",
                Description  = "integrationTestDescription",
                StartDate    = DateTime.Now,
                Organizer    = "integrationTestOrganizer",
                ImageContent = GetTestImage()
            };

            // act
            var actual = await client.PutAsJsonAsync("/api/OnlineEvent/0", onlineEvent);

            // assert
            Assert.True(actual.StatusCode == expected, $"{actual.StatusCode} was returned instead of {expected}");
        }
Beispiel #12
0
        public async Task <IActionResult> Post(OnlineEvent onlineEvent)
        {
            var output = await _onlineEventData.Insert(onlineEvent);

            return(Created("", output));
        }
Beispiel #13
0
 public void Online()
 {
     OnlinePage = true;
     LocalPage  = false;
     OnlineEvent?.Invoke(this, EventArgs.Empty);
 }