Ejemplo n.º 1
0
        public async Task <ActionResult <ApiResponse> > GetConditions([FromQuery] string name, [FromQuery] int page, [FromServices] IBittnService bittnService)
        {
            var response = await bittnService.GetConditions(new GetConditionsRequest
            {
                Name      = name,
                PageIndex = page
            });

            return(ApiResponseHelper.Ok <IllnessDetails>($"{response?.Data?.Count() ?? 0} condition(s) found.", response));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <ApiResponse> > CancelBooking(int bookingId, [FromServices] IBittnService bittnService)
        {
            var response = await bittnService.CancelBooking(new CancelBookingRequest
            {
                BookingId = bookingId
            });

            return(response.Deleted
                ? ApiResponseHelper.Ok("Booking deleted.", response)
                : ApiResponseHelper.Fail("No booking deleted.", response));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <ApiResponse> > GetBookings([FromQuery] int page, [FromQuery] string sortField, [FromQuery] bool?sortDescending, [FromServices] IBittnService bittnService)
        {
            var response = await bittnService.GetBookings(new GetBookingsRequest
            {
                PageIndex      = page,
                SortField      = sortField,
                SortDescending = sortDescending
            });

            return(ApiResponseHelper.Ok <BookingDetails>($"{response?.Data?.Count() ?? 0} booking(s) found.", response));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <ApiResponse> > FindHelp([FromBody] FindHelpApiRequest request, [FromServices] IBittnService bittnService)
        {
            var response = await bittnService.FindHelp(new FindHelpRequest
            {
                ConditionId    = request.ConditionId,
                SeverityLevel  = request.Severity,
                PageIndex      = request.Page,
                SortField      = request.SortField,
                SortDescending = request.SortDescending
            });

            return(ApiResponseHelper.Ok <HelpDetails>($"{response?.Data?.Count() ?? 0} help found.", response));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <ApiResponse> > BookPatient([FromBody] BookPatientApiRequest request, [FromServices] IBittnService bittnService)
        {
            var response = await bittnService.BookPatient(new BookPatientRequest
            {
                ConditionId   = request.ConditionId,
                ConditionName = request.ConditionName,
                HelpId        = request.HelpId,
                HelpName      = request.HelpName,
                PatientName   = request.PatientName,
                SeverityLevel = request.Severity
            });

            return(ApiResponseHelper.Ok($"Booking created.", response));
        }
Ejemplo n.º 6
0
        public void Ok_Should_Return_Correctly()
        {
            var message = "message";
            var actual  = ApiResponseHelper.Ok(message);

            actual.Should().BeOfType <ActionResult <ApiResponse> >();

            actual.Result.Should().BeOfType <ObjectResult>();
            actual.Result.As <ObjectResult>().StatusCode.Should().Be(StatusCodes.Status200OK);

            actual.Result.As <ObjectResult>().Value.Should().BeOfType <ApiResponse>();
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Success.Should().Be(true);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Message.Should().Be(message);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Data.Should().BeNull();
        }
Ejemplo n.º 7
0
        public void Ok_Should_Return_Correctly_With_PagedResponse_Data()
        {
            var content = new PagedResponse <string>
            {
                Data          = new [] { "data" },
                PrevPageIndex = 111,
                NextPageIndex = 222
            };
            var message = "message";
            var actual  = ApiResponseHelper.Ok(message, content);

            actual.Should().BeOfType <ActionResult <ApiResponse> >();

            actual.Result.Should().BeOfType <ObjectResult>();
            actual.Result.As <ObjectResult>().StatusCode.Should().Be(StatusCodes.Status200OK);

            actual.Result.As <ObjectResult>().Value.Should().BeOfType <ApiResponse>();
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Success.Should().Be(true);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Message.Should().Be(message);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Data.Should().Be(content.Data);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Navigation.PrevPageIndex.Should().Be(content.PrevPageIndex);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Navigation.NextPageIndex.Should().Be(content.NextPageIndex);
        }
Ejemplo n.º 8
0
        public async Task <ActionResult <ApiResponse> > LogIn([FromBody] SecurityRequest request, [FromServices] ISecurityService securityService)
        {
            var response = await securityService.LogIn(request);

            return(ApiResponseHelper.Ok("User logged in.", response));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult <ApiResponse> > DeleteRemark(string remarkId, [FromServices] IRemarksService remarksService)
        {
            await remarksService.DeleteRemark(remarkId);

            return(ApiResponseHelper.Ok("Remark deleted.", remarkId));
        }
Ejemplo n.º 10
0
        public async Task <ActionResult <ApiResponse> > UpdateRemark(string remarkId, [FromBody] UpdateRemarkRequest updates, [FromServices] IRemarksService remarksService)
        {
            await remarksService.UpdateRemark(remarkId, updates);

            return(ApiResponseHelper.Ok("Remark updated.", remarkId));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult <ApiResponse> > GetRemarks([FromQuery] string filter, [FromServices] IRemarksService remarksService)
        {
            var response = await remarksService.GetRemarks(filter);

            return(ApiResponseHelper.Ok($"{response.Count()} remark(s) found.", response));
        }