Beispiel #1
0
        public Task <IActionResult> CreateNotificationSubscription(NotificationSubscriptionCreateRequest request)
        {
            var currentUserId = PlatformUtils.GetIdentityUserId(User);
            var existingUser  = AuthorizationLayer.GetUserById(currentUserId);

            if (existingUser == null)
            {
                return(Task.FromResult <IActionResult>(NotFound()));
            }

            var model = new NotificationSubscription
            {
                UserId = existingUser.Id,
                Url    = request.Url,
                P256dh = request.P256dh,
                Auth   = request.Auth
            };
            //Invocazione del service layer
            var validations = BasicLayer.CreateNotificationSubscription(model);

            if (validations.Count > 0)
            {
                return(BadRequestTask(validations));
            }

            //Return contract
            return(Reply(new OkResponse {
                Status = true
            }));
        }