public object get(string userGUID)
        {
            LeaveDaoHelper leaveHelper = LeaveDaoHelper.getInstance();
            string         companyGUID = leaveHelper.GetCompanyGUIDByUserID(userGUID);

            return(new { companyGUID = companyGUID });
        }
Ejemplo n.º 2
0
        internal static AuthenticationResponse checkAuthentication(AuthenticationRequest authenticationRequest, HttpRequestMessage request)
        {
            AuthenticationResponse authenticationResponse = new AuthenticationResponse();

            try
            {
                string CompanyGuid = leaveDaoHelper.GetCompanyGUIDByUserID(authenticationRequest.Username);
                if (CompanyGuid != null &&
                    CompanyGuid != String.Empty &&
                    Apiv2.ELeave.Util.Common.getInstance().EscapeSql(CompanyGuid) == authenticationRequest.Company_Id)
                {
                    AuthDAL.createAuthCode(authenticationRequest.Username, authenticationRequest.Company_Id, CompanyGuid);
                    authenticationResponse.Success = true;
                }
                else
                {
                    authenticationResponse.Success = false;
                    authenticationResponse.Error   = new Error
                    {
                        Id      = ErrorCode.COMPANY_NOT_MATCHED,
                        Message = ErrorMessage.COMPANY_NOT_MATCHED
                    };
                    throw new HttpResponseException(request.CreateResponse(HttpStatusCode.Unauthorized, authenticationResponse));
                }
            }
            catch (Exception ex)
            {
                authenticationResponse.Success = false;
                authenticationResponse.Error   = new Error
                {
                    Id      = ErrorCode.INTERNAL_ERROR,
                    Message = ex.Message
                };
                throw new HttpResponseException(request.CreateResponse(HttpStatusCode.InternalServerError, authenticationResponse));
            }
            return(authenticationResponse);
        }