/*  public T responceData(Func<int, T> logicFunc)
         * {
         *    if (!request.Headers.Contains(keyAuthorization))
         *    {
         *        responce.generateThrowWithMessage(HttpStatusCode.BadRequest, "No Authorization field");
         *    }
         *
         *    int id = getAuthorizationUserId();
         *    model = logicFunc(id);
         *    return model;
         * }*/

        public int getUserId()
        {
            if (!request.Headers.Contains(keyAuthorization))
            {
                responce.generateThrowWithMessage(HttpStatusCode.BadRequest, "No Authorization field");
            }
            int userId = getAuthorizationUserId();

            updateLastActiveTime(userId);
            return(userId);
        }
        public PreviewProfileModel LogInUser()
        {
            GenerateResponce    responce = new GenerateResponce(Request);
            PreviewProfileModel model    = new PreviewProfileModel();

            if (Request.Headers.Contains("Authorization"))
            {
                string basic = Request.Headers.GetValues("Authorization").First();
                model = logic.logInUser(basic);

                if (model == null)
                {
                    responce.generateThrowWithMessage(HttpStatusCode.Unauthorized, "No SignUp user");
                }
                return(model);
            }

            responce.generateThrowWithMessage(HttpStatusCode.BadRequest, "No Authorization field");
            return(model);
        }
        public PreviewProfileModel SingUpUser(SignUpModel model)
        {
            GenerateResponce responce = new GenerateResponce(Request);

            //if (model != null)
            {
                PreviewProfileModel modelProfile = logic.signUpUser(model);
                if (modelProfile != null)
                {
                    responce.generateResponce(HttpStatusCode.OK);
                }
                else
                {
                    responce.generateThrowWithMessage(HttpStatusCode.Unauthorized, "User with this login exist");
                }

                return(modelProfile);
            }
            //return responce.generateError(HttpStatusCode.InternalServerError, "Empty data");
        }