public void Create_when_give_correctly_dto()
        {
            ScheduleEventDTO scheduleEventDTO = new ScheduleEventDTO()
            {
                EventType = ScheduleEventType.CREATED,
                SessionId = Guid.NewGuid()
            };

            Guid scheduleId = scheduleEventService.Create(scheduleEventDTO);

            Assert.NotEqual(scheduleId.ToString(), Guid.Empty.ToString());
        }
Example #2
0
 public Guid Create(ScheduleEventDTO entityDTO)
 {
     try
     {
         ScheduleEvent scheduleEvent = new ScheduleEvent(entityDTO.EventType, Guid.NewGuid(), entityDTO.SessionId);
         _eventRepository.Create(scheduleEvent);
         return(scheduleEvent.BaseEntityId);
     }catch (Exception e)
     {
         throw new InternalServerErrorException();
     }
 }
        public IActionResult CreateEvent(ScheduleEventDTO dto)
        {
            if (!IsValidAuthenticationRole("Patient"))
            {
                return(StatusCode(403));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    _scheduleEventService.Create(dto);
                }
                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }
Example #4
0
        public async Task Create_event()
        {
            HttpClient client = _factory.CreateClient();

            client.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiJiNzA1NmZjYy00OGZhLTRkZjUtOWU5My0zMzRhYjc1OTVkYWEiLCJyb2xlIjoiUGF0aWVudCIsIm5iZiI6MTYxMDMxMTY3NiwiZXhwIjoxNjQxODQ3Njc2LCJpYXQiOjE2MTAzMTE2NzZ9.3bLgIjzH2hXzPdbRz910Q3Jwk2w-SBNE-WaUVGzk3I8");
            ScheduleEventDTO scheduleEventDTO = new ScheduleEventDTO()
            {
                SessionId = Guid.NewGuid(),
                EventType = Domain.Events.ScheduleEventType.EXIT
            };

            var myContent   = JsonConvert.SerializeObject(scheduleEventDTO);
            var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
            var byteContent = new ByteArrayContent(buffer);

            byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = await client.PostAsync("/api/ScheduleEvent/", byteContent);

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
        public void Create_when_give_incorrectly_dto()
        {
            ScheduleEventDTO scheduleEventDTO = null;

            Assert.Throws <InternalServerErrorException>(() => scheduleEventService.Create(scheduleEventDTO));
        }