/// <summary>
        /// Returns true if the access point is registered or updated and false if the access point was not found during update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <CommandResult> RegisterAsync(RegisterAccessPointRequestModel model)
        {
            using (var connection = await this.connectionFactory.CreateConnectionAsync(true))
                using (var transaction = connection.BeginTransaction())
                {
                    try
                    {
                        var dbResult = await this.database.InsertAccessPointIfNotExistsAsync(
                            serialNumber : model.SerialNumber,
                            transaction : transaction,
                            description : model.Description,
                            IsActive : model.IsActive,
                            accessLevel : model.AccessLevel,
                            direction : model.Direction
                            );

                        if (dbResult.IsInserted)
                        {
                            await this.database.DeleteUnknownAccessPointAsync(model.SerialNumber, transaction);
                        }

                        transaction.Commit();

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

                        throw;
                    }
                }
        }
Пример #2
0
        public async Task <IActionResult> RegisterAsync(RegisterAccessPointRequestModel model)
        {
            var command       = this.commandFactory.CreateRegisterAccessPointCommand();
            var commandResult = await command.RegisterAsync(model);

            if (commandResult.Success)
            {
                return(this.Ok());
            }
            else
            {
                return(this.BadRequest(commandResult));
            }
        }
Пример #3
0
 public static Task <HttpResponseMessage> RegisterAccessPointAsync(RegisterAccessPointRequestModel requestModel, String authToken)
 {
     return(PostAsync("/administration/api/accessPoint/register", requestModel, authToken));
 }