public OrganizationResponse GetOrganizationByKey(OrganizationRequest request)
        {
            try
            {
                Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao IOrganizationDao = new EF.EntityOrganizationDao();
                Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(IOrganizationDao);

                // Transform SurveyInfo data transfer object to SurveyInfo business object
                OrganizationBO Organization = Mapper.ToBusinessObject(request.Organization);
                var            response     = new OrganizationResponse(request.RequestId);

                if (Epi.Web.BLL.Common.ValidateAdmin(request.AdminSecurityKey.ToString()))
                {
                    // Validate client tag, access token, and user credentials

                    if (!ValidRequest(request, response, Validate.All))
                    {
                        return(response);
                    }

                    OrganizationBO OrganizationBO = Implementation.GetOrganizationByKey(Organization.OrganizationKey.ToString());
                    response.OrganizationList = new List <OrganizationDTO>();

                    (response.OrganizationList).Add(Mapper.ToDataTransferObjects(OrganizationBO));


                    return(response);
                }
                else
                {
                    response.Message = "Invalid Admin Key";

                    return(response);
                }
            }
            catch (Exception ex)
            {
                CustomFaultException customFaultException = new CustomFaultException();
                customFaultException.CustomMessage = ex.Message;
                customFaultException.Source        = ex.Source;
                customFaultException.StackTrace    = ex.StackTrace;
                customFaultException.HelpLink      = ex.HelpLink;
                throw new FaultException <CustomFaultException>(customFaultException);
            }
        }
Example #2
0
 public bool IsValidOrgKey(SurveyInfoRequest request)
 {
     try
     {
         bool validSurvey = false;
         //var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]);
         if (request.Criteria.SurveyIdList.Count == 0)
         {
             Epi.Web.Interfaces.DataInterfaces.IOrganizationDao organizationDao = new EF.EntityOrganizationDao();
             Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(organizationDao);
             Epi.Web.Common.BusinessObject.OrganizationBO ogranizationBO = Implementation.GetOrganizationByKey(request.Criteria.OrganizationKey.ToString());
             if (ogranizationBO == null)
             {
                 validSurvey = false;
             }
             else
             {
                 validSurvey = true;
             }
         }
         else
         {
             Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao();
             Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao);
             validSurvey = Implementation.IsSurveyInfoValidByOrgKey(request.Criteria.SurveyIdList[0].ToString(), request.Criteria.OrganizationKey.ToString());
         }
         return(validSurvey);
     }
     catch (Exception ex)
     {
         CustomFaultException customFaultException = new CustomFaultException();
         customFaultException.CustomMessage = ex.Message;
         customFaultException.Source        = ex.Source;
         customFaultException.StackTrace    = ex.StackTrace;
         customFaultException.HelpLink      = ex.HelpLink;
         throw new FaultException <CustomFaultException>(customFaultException);
     }
 }