public async Task <AdminModel> RegisterPartnerAdminAsync([FromBody] AdminRegisterModel model) { try { var(error, admin) = await _adminsService.RegisterPartnerAdminAsync(model); if (error == AdminServiceCreateResponseError.None) { model.Password = null; model.Email = model.Email.SanitizeEmail(); await _auditLogPublisher.PublishAuditLogAsync(admin.Id, model.ToJson(), ActionType.PartnerAdminCreate); return(_mapper.Map <AdminModel>(admin)); } switch (error) { case AdminServiceCreateResponseError.AlreadyRegistered: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.AdminAlreadyRegistered); case AdminServiceCreateResponseError.InvalidEmailOrPasswordFormat: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.InvalidEmailOrPasswordFormat); default: throw LykkeApiErrorException.BadRequest(new LykkeApiErrorCode(error.ToString())); } } catch (ClientApiException exception) { throw new ValidationApiException(exception.ErrorResponse); } }
public async Task <AdminModel> RegisterPartnerAdminAsync([FromBody] AdminRegisterModel model) { try { var(error, admin) = await _adminsService.RegisterPartnerAdminAsync(model); switch (error) { case AdminServiceCreateResponseError.None: return(_mapper.Map <AdminModel>(admin)); case AdminServiceCreateResponseError.AlreadyRegistered: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.AdminAlreadyRegistered); case AdminServiceCreateResponseError.InvalidEmailOrPasswordFormat: throw LykkeApiErrorException.BadRequest(ApiErrorCodes.Service.InvalidEmailOrPasswordFormat); default: throw LykkeApiErrorException.BadRequest(new LykkeApiErrorCode(error.ToString())); } } catch (ClientApiException exception) { throw new ValidationApiException(exception.ErrorResponse); } }