public async Task UserCanCreateRequest()
        {
            var request = new CreateRateRequestRequest
            {
                ValueRate   = 10000,
                Description = "Bla bla bla"
            };

            var response = await Api.Client.WithRole(RoleNames.User).PostAsJsonAsync(_uri + "/request", request);

            response.StatusCode.Should().BeEquivalentTo(200);
            response.Content.Should().NotBeNull();
        }
        public async Task UserCannotCreateRequestWithInvalidData(decimal valueRate, string description)
        {
            var request = new CreateRateRequestRequest
            {
                ValueRate   = valueRate,
                Description = description
            };

            var response = await Api.Client.WithRole(RoleNames.User).PostAsJsonAsync(_uri + "/request", request);

            response.StatusCode.Should().BeEquivalentTo(400);
            response.Content.Should().NotBeNull();
        }
        public async Task CreateSalaryRateRequest(int id, CreateRateRequestRequest request)
        {
            Check.Value(request, "Request").NotNull();
            request.Validate(ImmediateValidator.Instance);

            using (var conn = _dbConnFactory.CreateConnection())
            {
                var user = await conn.GetUserById(id);

                Check.Value(user, "Request").NotNull("User doesn't exist");

                await conn.ExecuteAsync("INSERT INTO salary_rate_requests (user_id, request_id, value_rate, description, " +
                                        "invited_at, status) VALUES (@UserId, @RequestId, @ValueRate, @Description, @InvitedAt, " +
                                        "@Status)", new SalaryRateRequest
                {
                    UserId      = id,
                    RequestId   = Guid.NewGuid(),
                    ValueRate   = request.ValueRate,
                    Description = request.Description,
                    InvitedAt   = DateTime.Now,
                    Status      = 0
                });
            }
        }
Beispiel #4
0
 public async Task CreateRequest([FromBody] CreateRateRequestRequest request)
 {
     await _rateRequestService.CreateSalaryRateRequest(this.GetUserId(), request);
 }