Esempio n. 1
0
        public async Task <CommandResult> UpdateAsync(UpdateAccessPointRequestModel requestModel)
        {
            using (var connection = await this.sqlConnectionFactory.CreateConnectionAsync(true))
                using (var transaction = connection.BeginTransaction())
                {
                    try
                    {
                        var dbResult = await database.UpdateAccessPointAsync(
                            id : requestModel.Id,
                            transaction : transaction,
                            description : requestModel.Description,
                            isActive : requestModel.IsActive,
                            accessLevel : requestModel.AccessLevel,
                            direction : requestModel.Direction,
                            isDeleted : requestModel.IsDeleted
                            );

                        transaction.Commit();

                        return(CommandResult.FromDbResult(dbResult));
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateAsync(UpdateAccessPointRequestModel requestModel)
        {
            var command       = this.commandFactory.CreateUpdateAccessPointCommand();
            var commandResult = await command.UpdateAsync(requestModel);

            if (commandResult.Success)
            {
                return(this.Ok());
            }
            else
            {
                return(this.NotFound());
            }
        }
        public async Task Update_When_All_Properties_Provided()
        {
            var assertDatabase = await RfidDatabaseAssert.CreateAsync();

            var userRM             = Examples.Administrator();
            var accessPointRM      = Examples.AccessPoint();
            var accessPointId      = 0;
            var updatedDescription = $"{Guid.NewGuid()}";

            await RfidHttpClient.RegisterUserAsync(userRM);

            using (var authTokenResponseMessage = await RfidHttpClient.GenerateAuthTokenAsync(userRM))
            {
                var authToken = await AuthTokenHelper.FromHttpResponseMessageAsync(authTokenResponseMessage);

                var token = await authToken.GetTokenAsync();

                using (var httpResponse = await RfidHttpClient.RegisterAccessPointAsync(accessPointRM, token))
                {
                    RfidAssert.AssertHttpResponse(httpResponse, System.Net.HttpStatusCode.OK);
                }

                accessPointId = await RfidDatabase.GetAccessPointIdBySerialNumberAsync(accessPointRM.SerialNumber);

                var updateRm = new UpdateAccessPointRequestModel
                {
                    Id          = accessPointId,
                    AccessLevel = AccessLevel.High,
                    Description = updatedDescription,
                    Direction   = AccessPointDirectionType.Exit,
                };

                using (var httpResponse = await RfidHttpClient.UpdateAccessPointAsync(updateRm, token))
                {
                    RfidAssert.AssertHttpResponse(httpResponse, System.Net.HttpStatusCode.OK);
                }
            }

            await assertDatabase.AssertCntAsync(userRM, accessPointRM);

            await assertDatabase.AssertStateAsync("access_control.AccessPoints", accessPointId, new
            {
                Id           = accessPointId,
                LevelId      = (int)AccessLevel.High,
                DirectionId  = (int)AccessPointDirectionType.Exit,
                SerialNumber = accessPointRM.SerialNumber,
                Description  = updatedDescription
            });
        }
Esempio n. 4
0
 public static Task <HttpResponseMessage> UpdateAccessPointAsync(UpdateAccessPointRequestModel requestModel, String authToken)
 {
     return(PatchAsync($"/administration/api/accessPoint/update", requestModel, authToken));
 }