Example #1
0
        public async Task CanCreateDriver()
        {
            await sut.Execute(CommonDataSet.BookingBindingModel);

            Assert.Equal(1, context.Object.Bookings.Local.Count);
            context.Verify(x => x.SaveChangesAsync(), Times.Once());
        }
Example #2
0
        public async Task <ActionResult> Post([FromBody] BookingRequest bookingRequest)
        {
            var userId = User.Claims.Single(c => c.Type == "emails").Value;

            if (!string.IsNullOrEmpty(bookingRequest.UserId) && bookingRequest.UserId != userId)
            {
                return(BadRequest("If userId is used its value must be the logged user id"));
            }

            await _createBookingCommand.Execute(bookingRequest);

            return(Ok());
        }
Example #3
0
        public async Task <ActionResult> Post([FromBody] BookingRequest bookingRequest)
        {
            var userId = User.Claims.First(c => c.Type == "emails").Value;

            if (!string.IsNullOrEmpty(bookingRequest.UserId) && bookingRequest.UserId != userId)
            {
                return(BadRequest("Значение userId должно быть зарегистрированным идентификатором пользователя"));
            }

            bookingRequest.UserId = userId;

            await _createBookingCommand.Execute(bookingRequest);

            return(Ok());
        }