Exemple #1
0
        public IActionResult GetAllAuthByCurrentUser([FromQuery] GetAllByCurrentUserRequestModel requestModel, [FromHeader] string displayLanguage)
        {
            var responseModel = new ApiResponseModel <List <Data.Entity.Auth> >();

            responseModel.DisplayLanguage = displayLanguage;

            if (requestModel.EmployeeId <= 0)
            {
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                responseModel.ResultStatusMessage = "EmployeeId Id Must Be Entered";
                return(BadRequest(responseModel));
            }
            try
            {
                responseModel.Data                = _profileDetailService.GetAllAuthByCurrentUser(requestModel.EmployeeId);
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Success;
                responseModel.ResultStatusMessage = "Success";
                return(Ok(responseModel));
            }
            catch (Exception ex)
            {
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                responseModel.ResultStatusMessage = ex.Message;
                responseModel.Data = null;
                return(StatusCode(StatusCodes.Status500InternalServerError, responseModel));
            }
        }
        //[TokenAuthorizeFilter]
        public IActionResult GetAllAuthByCurrentUser([FromQuery] GetAllByCurrentUserRequestModel requestModel, [FromHeader] string displayLanguage)
        {
            var responseModel = new Return <List <Data.Entity.Auth> >();

            responseModel.DisplayLanguage = displayLanguage;

            if (requestModel.PersonnelId <= 0)
            {
                responseModel.Status  = ResultStatusCodeStatic.BadRequest;
                responseModel.Message = "Personnel Id Must Be Entered";
                responseModel.Success = false;
                ReturnError error = new ReturnError();
                error.Key            = "500";
                error.Message        = "Personnel Id Must Be Entered";
                error.Code           = 500;
                responseModel.Errors = new List <ReturnError>();
                responseModel.Errors.Add(error);
                responseModel.Data = null; //hata oluştugundan dolayı Data null olarak dönülür.
                return(BadRequest(responseModel));
            }
            try
            {
                responseModel.Data    = _profileDetailService.GetAllAuthByCurrentUser(requestModel.PersonnelId);
                responseModel.Status  = ResultStatusCodeStatic.Success;
                responseModel.Message = "Success";
                responseModel.Success = true;
                return(Ok(responseModel));
            }
            catch (Exception ex)
            {
                responseModel.Status  = ResultStatusCodeStatic.InternalServerError;
                responseModel.Message = "An error occurred";
                responseModel.Success = false;
                ReturnError error = new ReturnError();
                error.Key            = "500";
                error.Message        = ex.Message;
                error.Code           = 500;
                responseModel.Errors = new List <ReturnError>();
                responseModel.Errors.Add(error);
                responseModel.Data = null; //hata oluştugundan dolayı Data null olarak dönülür.
                return(StatusCode(StatusCodes.Status500InternalServerError, responseModel));
            }
        }
Exemple #3
0
        public ApiResponseModel <List <Auth> > GetAllByCurrentUser(string userToken)
        {
            ApiResponseModel <List <Auth> > result = new ApiResponseModel <List <Auth> >();

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl);
                httpClient.DefaultRequestHeaders.Accept.Clear();
                httpClient.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken);
                var portalApiRequestModel = new GetAllByCurrentUserRequestModel();
                portalApiRequestModel.UserToken = userToken;
                HttpResponseMessage response = httpClient.PostAsJsonAsync(string.Format("Auth/GetAllByCurrentUser"), portalApiRequestModel).Result;
                result = response.Content.ReadAsAsync <ApiResponseModel <List <Auth> > >().Result;
            }
            return(result);
        }
        public ApiResponseModel <List <Data.Entity.Auth> > GetAllByCurrentUser([FromBody] GetAllByCurrentUserRequestModel requestModel)
        {
            var responseModel = new ApiResponseModel <List <Data.Entity.Auth> >();

            try
            {
                // token bilgisinde ilgili user'ın profileid bilgisi elde edilir
                var userProfileId = _userTokenService.GetByToken(requestModel.UserToken).ProfileId;

                responseModel.Data                = _authService.GetAllByProfileId(userProfileId);
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Success;
                responseModel.ResultStatusMessage = "Success";
            }
            catch (Exception ex)
            {
                responseModel.ResultStatusCode    = ResultStatusCodeStatic.Error;
                responseModel.ResultStatusMessage = ex.Message;
            }
            return(responseModel);
        }