public FormsHierarchyResponse GetFormsHierarchy(FormsHierarchyRequest FormsHierarchyRequest) { FormsHierarchyResponse FormsHierarchyResponse = new FormsHierarchyResponse(); List <SurveyResponseBO> AllResponsesIDsList = new List <SurveyResponseBO>(); //1- Get All form ID's Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); List <FormsHierarchyBO> RelatedFormIDsList = Implementation.GetFormsHierarchyIdsByRootId(FormsHierarchyRequest.SurveyInfo.SurveyId); FormsHierarchyResponse.FormsHierarchy = Mapper.ToFormHierarchyDTO(RelatedFormIDsList); //2- Get all Responses ID's //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyResponseDao ISurveyResponseDao = entityDaoFactory.SurveyResponseDao; //Epi.Web.BLL.SurveyResponse Implementation1 = new Epi.Web.BLL.SurveyResponse(ISurveyResponseDao); //if (!string.IsNullOrEmpty(FormsHierarchyRequest.SurveyResponseInfo.ResponseId)) //{ // AllResponsesIDsList = Implementation1.GetResponsesHierarchyIdsByRootId(FormsHierarchyRequest.SurveyResponseInfo.ResponseId); //} //else //{ // AllResponsesIDsList = null; //} ////3 Combining the lists. //FormsHierarchyResponse.FormsHierarchy = Mapper.ToFormHierarchyDTO(CombineLists(RelatedFormIDsList, AllResponsesIDsList)); return(FormsHierarchyResponse); }
public SurveyInfoResponse GetFormChildInfo(SurveyInfoRequest pRequest) { try { SurveyInfoResponse result = new SurveyInfoResponse(pRequest.RequestId); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); Dictionary <string, int> ParentIdList = new Dictionary <string, int>(); foreach (var item in pRequest.SurveyInfoList) { ParentIdList.Add(item.SurveyId, item.ViewId); } result.SurveyInfoList = Mapper.ToDataTransferObject(implementation.GetChildInfoByParentId(ParentIdList)); return(result); } 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); } }
public SurveyResponseBO UpdateSurveyResponse(SurveyResponseBO pValue) { SurveyResponseBO result = pValue; //Check if this respose has prent string ParentId = SurveyResponseDao.GetResponseParentId(pValue.ResponseId); Guid ParentIdGuid = Guid.Empty; if (!string.IsNullOrEmpty(ParentId)) { ParentIdGuid = new Guid(ParentId); } Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(ISurveyInfoDao); var List = Implementation.GetSurveyControlList(pValue.SurveyId); SurveyResponseJson SurveyResponseJson = new SurveyResponseJson(); var json = SurveyResponseJson.GetSurveyResponseJson(pValue, List); pValue.Json = json; //if ( pValue.Status == 2 && ParentIdGuid!= Guid.Empty ) //{ //if (!string.IsNullOrEmpty(ParentId) && ParentId != Guid.Empty.ToString() && pValue.Status == 2) // { // //read the child // SurveyResponseBO Child = this.SurveyResponseDao.GetSingleResponse(pValue.ResponseId); // // read the parent // SurveyResponseBO Parent = this.SurveyResponseDao.GetSingleResponse(ParentId); // //copy and update // Parent.XML = Child.XML; // this.SurveyResponseDao.UpdateSurveyResponse(Parent); // result = Parent; // //Check if this child has a related form (subchild) // List<SurveyResponseBO> Children = this.GetResponsesHierarchyIdsByRootId(Child.ResponseId); // if (Children.Count() > 1) // { // SurveyResponseBO NewChild = Children[1]; // NewChild.RelateParentId = Parent.ResponseId; // this.SurveyResponseDao.UpdateSurveyResponse(NewChild); // } // // Set child recod UserId // Child.UserId = pValue.UserId; // // delete the child // this.DeleteSingleSurveyResponse(Child); //} //else //{ //Check if the record existes.If it does update otherwise insert new this.SurveyResponseDao.UpdateSurveyResponse(pValue); SurveyResponseBO SurveyResponseBO = SurveyResponseDao.GetResponseXml(pValue.ResponseId); // } return(result); }
public SourceTablesResponse GetSourceTables(SourceTablesRequest Request) { SourceTablesResponse DropDownsResponse = new SourceTablesResponse(); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); DropDownsResponse.List = Mapper.ToSourceTableDTO(Implementation.GetSourceTables(Request.SurveyId)); return(DropDownsResponse); }
public bool UpdateSourceTable(SourceTablesRequest SourceTablesRequest) { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(ISurveyInfoDao); try { return(Implementation.UpdateSourceTable(SourceTablesRequest.List, SourceTablesRequest.SurveyId)); } catch (Exception ex) { return(false); throw ex; } }
public bool ValidateOrganization(OrganizationRequest Request) { bool IsValid; try { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(ISurveyInfoDao); IsValid = Implementation.ValidateOrganization(Request); } catch (Exception ex) { throw ex; } return(IsValid); }
public SurveyInfoResponse GetAllSurveysByOrgKey(string OrgKey) { SurveyInfoResponse SurveyInfoResponse = new SurveyInfoResponse(); try { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(ISurveyInfoDao); SurveyInfoResponse.SurveyInfoList = Mapper.ToDataTransferObject(Implementation.GetAllSurveysByOrgKey(OrgKey)); } catch (Exception ex) { throw ex; } return(SurveyInfoResponse); }
public SurveyControlsResponse GetSurveyControlList(SurveyControlsRequest pRequestMessage) { SurveyControlsResponse SurveyControlsResponse = new SurveyControlsResponse(); try { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(ISurveyInfoDao); SurveyControlsResponse = Implementation.GetSurveyControlList(pRequestMessage.SurveyId); } catch (Exception ex) { SurveyControlsResponse.Message = "Error"; throw ex; } return(SurveyControlsResponse); }
/// <summary> /// /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public SurveyInfoResponse GetSurveyInfo(SurveyInfoRequest surveyInfoRequest) { try { SurveyInfoResponse response = new SurveyInfoResponse(surveyInfoRequest.RequestId); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo surveyInfo = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); if (!ValidRequest(surveyInfoRequest, response, Validate.All)) { return(response); } var criteria = surveyInfoRequest.Criteria as SurveyInfoCriteria; string sort = criteria.SortExpression; List <string> SurveyIdList = new List <string>(); foreach (string id in criteria.SurveyIdList) { SurveyIdList.Add(id.ToUpper()); } List <SurveyInfoBO> bo = surveyInfo.GetSurveyInfoById(SurveyIdList); response.SurveyInfoList = Mapper.ToDataTransferObject(bo); 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); } }
public bool IsValidOrgKey(SurveyInfoRequest request) { try { bool validSurvey = false; //var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]); if (request.Criteria.SurveyIdList.Count == 0) { Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao organizationDao = new EFwcf.EntityOrganizationDao(); Epi.Web.BLL.Organization Implementation = new Epi.Web.BLL.Organization(organizationDao); Epi.Web.Enter.Common.BusinessObject.OrganizationBO ogranizationBO = Implementation.GetOrganizationByKey(request.Criteria.OrganizationKey.ToString()); if (ogranizationBO == null) { validSurvey = false; } else { validSurvey = true; } } else { Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EFwcf.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); } }
/// <summary> /// /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public SurveyInfoResponse GetSurveyInfo(SurveyInfoRequest pRequest) { try { SurveyInfoResponse result = new SurveyInfoResponse(pRequest.RequestId); //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao(); //Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); Epi.Web.Enter.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EFwcf.EntityDaoFactory(); Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); // Validate client tag, access token, and user credentials if (!ValidRequest(pRequest, result, Validate.All)) { return(result); } //Validate UserPublishKey exists if (pRequest.Criteria.UserPublishKey == null) { return(result); } var criteria = pRequest.Criteria as SurveyInfoCriteria; string sort = criteria.SortExpression; List <string> SurveyIdList = new List <string>(); foreach (string id in criteria.SurveyIdList) { SurveyIdList.Add(id.ToUpper()); } List <SurveyInfoBO> SurveyBOList = new List <SurveyInfoBO>(); // int ResponseMaxSize = 16384; int ResponseMaxSize = Int32.Parse(ConfigurationManager.AppSettings["maxBytesPerRead"]); int BandwidthUsageFactor = Int32.Parse(ConfigurationManager.AppSettings["BandwidthUsageFactor"]); Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao entityDaoFactory1 = new EFwcf.EntityOrganizationDao(); //Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao surveyInfoDao1 = entityDaoFactory1; Epi.Web.BLL.Organization implementation1 = new Epi.Web.BLL.Organization(surveyInfoDao1); bool ISValidOrg = implementation1.ValidateOrganization(pRequest.Criteria.OrganizationKey.ToString()); if (ISValidOrg) { if (pRequest.Criteria.ReturnSizeInfoOnly == true) { // add BandwidthUsageFactor PageInfoBO PageInfoBO = implementation.GetSurveySizeInfo(SurveyIdList, criteria.ClosingDate, criteria.OrganizationKey.ToString(), BandwidthUsageFactor, criteria.SurveyType, criteria.PageNumber, criteria.PageSize, ResponseMaxSize); result.PageSize = PageInfoBO.PageSize; result.NumberOfPages = PageInfoBO.NumberOfPages; } else { SurveyBOList = implementation.GetSurveyInfo(SurveyIdList, criteria.ClosingDate, criteria.OrganizationKey.ToString(), criteria.SurveyType, criteria.PageNumber, criteria.PageSize);//Default foreach (SurveyInfoBO surveyInfoBO in SurveyBOList) { result.SurveyInfoList.Add(Mapper.ToDataTransferObject(surveyInfoBO)); } } } else { result.Message = "Organization Key not found"; } return(result); } 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); } }
/// <summary> /// Set (add, update, delete) SurveyInfo value. /// </summary> /// <param name="request">SurveyInfoRequest request message.</param> /// <returns>SurveyInfoRequest response message.</returns> public SurveyInfoResponse SetSurveyInfo(SurveyInfoRequest request) { try { Epi.Web.Enter.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EFwcf.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); var response = new SurveyInfoResponse(request.RequestId); // Validate client tag, access token, and user credentials if (!ValidRequest(request, response, Validate.All)) { return(response); } // Transform SurveyInfo data transfer object to SurveyInfo business object var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]); // Validate SurveyInfo business rules if (request.Action != "Delete") { //if (!SurveyInfo.Validate()) //{ // response.Acknowledge = AcknowledgeType.Failure; // foreach (string error in SurveyInfo.ValidationErrors) // response.Message += error + Environment.NewLine; // return response; //} } // Run within the context of a database transaction. Currently commented out. // The Decorator Design Pattern. //using (TransactionDecorator transaction = new TransactionDecorator()) { bool validSurvey = false; //GetSurveyInfoByOrgKey //validSurvey = Implementation.IsSurveyInfoValidByOrgKeyAndPublishKey(SurveyInfo.SurveyId, SurveyInfo.OrganizationKey.ToString(), SurveyInfo.UserPublishKey); validSurvey = Implementation.IsSurveyInfoValidByOrgKey(SurveyInfo.SurveyId, SurveyInfo.OrganizationKey.ToString()); Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao entityDaoFactory1 = new EFwcf.EntityOrganizationDao(); Epi.Web.Enter.Interfaces.DataInterfaces.IOrganizationDao surveyInfoDao1 = entityDaoFactory1; Epi.Web.BLL.Organization implementation1 = new Epi.Web.BLL.Organization(surveyInfoDao1); bool ISValidOrg = implementation1.ValidateOrganization(SurveyInfo.OrganizationKey.ToString()); if (ISValidOrg) { if (validSurvey) { if (request.Action == "Create") { Implementation.InsertSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); } else if (request.Action == "Update") { Implementation.UpdateSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); response.Message = SurveyInfo.StatusText; } else if (request.Action == "UpdateMode") { Implementation.UpdateSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); response.Message = SurveyInfo.StatusText; //ImplementationAdmin.SendEmailToAdmins(SurveyInfo);// This process does not apply for EWE. } else if (request.Action == "Delete") { var criteria = request.Criteria as SurveyInfoCriteria; var survey = Implementation.GetSurveyInfoById(SurveyInfo.SurveyId); try { if (Implementation.DeleteSurveyInfo(survey)) { response.RowsAffected = 1; } else { response.RowsAffected = 0; } } catch { response.RowsAffected = 0; } } } else { response.Message = "SurveyId And/or Publish Key are invalid."; } } else { response.Message = "Organization Key is invalid."; } } 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); } }
/// <summary> /// /// </summary> /// <param name="pRequest"></param> /// <returns></returns> public SurveyAnswerResponse GetFormResponseList(SurveyAnswerRequest pRequest) { try { SurveyAnswerResponse result = new SurveyAnswerResponse(pRequest.RequestId); Epi.Web.Interfaces.DataInterfaces.IDaoFactory entityDaoFactory = new EF.EntityDaoFactory(); Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao ISurveyResponseDao = entityDaoFactory.SurveyResponseDao; Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(ISurveyResponseDao, ISurveyInfoDao); SurveyAnswerCriteria criteria = pRequest.Criteria; //result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetFormResponseListById(pRequest.Criteria.SurveyId, pRequest.Criteria.PageNumber, pRequest.Criteria.IsMobile)); result.SurveyResponseList = Mapper.ToDataTransferObject(Implementation.GetFormResponseListById(criteria));//Pain point //Query The number of records //result.NumberOfPages = Implementation.GetNumberOfPages(pRequest.Criteria.SurveyId, pRequest.Criteria.IsMobile); //result.NumberOfResponses = Implementation.GetNumberOfResponses(pRequest.Criteria.SurveyId); result.NumberOfPages = Implementation.GetNumberOfPages(pRequest.Criteria); result.NumberOfResponses = Implementation.GetNumberOfResponses(pRequest.Criteria); //Get form info //Interfaces.DataInterface.IFormInfoDao surveyInfoDao = new EF.EntityFormInfoDao(); //Epi.Web.BLL.FormInfo ImplementationFormInfo = new Epi.Web.BLL.FormInfo(surveyInfoDao); //result.FormInfo = Mapper.ToFormInfoDTO(ImplementationFormInfo.GetFormInfoByFormId(pRequest.Criteria.SurveyId, false, pRequest.Criteria.UserId)); SurveyInfoResponse response = new SurveyInfoResponse(pRequest.RequestId); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = entityDaoFactory.SurveyInfoDao; Epi.Web.BLL.SurveyInfo surveyInfo = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); if (!ValidRequest(pRequest, response, Validate.All)) { return(result); } List <string> SurveyIdList = new List <string>(); SurveyIdList.Add(pRequest.Criteria.SurveyId.ToUpper()); List <SurveyInfoBO> bo = surveyInfo.GetSurveyInfoById(SurveyIdList); result.SurveyInfo = Mapper.ToDataTransferObject(bo)[0]; return(result); } 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); } }
/// <summary> /// Set (add, update, delete) SurveyInfo value. /// </summary> /// <param name="request">SurveyResponse request message.</param> /// <returns>SurveyResponse response message.</returns> public SurveyAnswerResponse SetSurveyAnswer(SurveyAnswerRequest request) { try { Epi.Web.Interfaces.DataInterfaces.ISurveyResponseDao SurveyResponseDao = new EF.EntitySurveyResponseDao(); Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao ISurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyResponse Implementation = new Epi.Web.BLL.SurveyResponse(SurveyResponseDao, ISurveyInfoDao); SurveyAnswerResponse response = new SurveyAnswerResponse(request.RequestId); // Validate client tag, access token, and user credentials if (!ValidRequest(request, response, Validate.All)) { return(response); } // Transform SurveyResponse data transfer object to SurveyResponse business object SurveyResponseBO SurveyResponse = Mapper.ToBusinessObject(request.SurveyAnswerList)[0]; // Validate SurveyResponse business rules if (request.Action != "Delete") { //if (!SurveyResponse.Validate()) //{ // response.Acknowledge = AcknowledgeType.Failure; // foreach (string error in SurveyResponse.ValidationErrors) // response.Message += error + Environment.NewLine; // return response; //} } // Run within the context of a database transaction. Currently commented out. // The Decorator Design Pattern. //using (TransactionDecorator transaction = new TransactionDecorator()) { if (request.Action.Equals("Create", StringComparison.OrdinalIgnoreCase)) { Implementation.InsertSurveyResponse(SurveyResponse); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); } else if (request.Action.Equals("CreateChild", StringComparison.OrdinalIgnoreCase)) { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao SurveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation1 = new Epi.Web.BLL.SurveyInfo(SurveyInfoDao); SurveyInfoBO SurveyInfoBO = Implementation1.GetParentInfoByChildId(SurveyResponse.SurveyId); Implementation.InsertChildSurveyResponse(SurveyResponse, SurveyInfoBO, request.SurveyAnswerList[0].RelateParentId); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); List <SurveyResponseBO> List = new List <SurveyResponseBO>(); List.Add(SurveyResponse); Implementation.InsertSurveyResponse(List, request.Criteria.UserId, true); } else if (request.Action.Equals("Update", StringComparison.OrdinalIgnoreCase)) { Implementation.UpdateSurveyResponse(SurveyResponse); response.SurveyResponseList.Add(Mapper.ToDataTransferObject(SurveyResponse)); } else if (request.Action.Equals("Delete", StringComparison.OrdinalIgnoreCase)) { var criteria = request.Criteria as SurveyAnswerCriteria; var survey = Implementation.GetSurveyResponseById(new List <string> { SurveyResponse.SurveyId }, SurveyResponse.UserPublishKey); foreach (SurveyResponseBO surveyResponse in survey) { try { if (Implementation.DeleteSurveyResponse(surveyResponse)) { response.RowsAffected += 1; } } catch { //response.RowsAffected = 0; } } } } 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); } }
/// <summary> /// Set (add, update, delete) SurveyInfo value. /// </summary> /// <param name="request">SurveyInfoRequest request message.</param> /// <returns>SurveyInfoRequest response message.</returns> public SurveyInfoResponse SetSurveyInfo(SurveyInfoRequest request) { try { Epi.Web.Interfaces.DataInterfaces.ISurveyInfoDao surveyInfoDao = new EF.EntitySurveyInfoDao(); Epi.Web.BLL.SurveyInfo Implementation = new Epi.Web.BLL.SurveyInfo(surveyInfoDao); var response = new SurveyInfoResponse(request.RequestId); // Validate client tag, access token, and user credentials if (!ValidRequest(request, response, Validate.All)) { return(response); } // Transform SurveyInfo data transfer object to SurveyInfo business object var SurveyInfo = Mapper.ToBusinessObject(request.SurveyInfoList[0]); // Validate SurveyInfo business rules if (request.Action != "Delete") { //if (!SurveyInfo.Validate()) //{ // response.Acknowledge = AcknowledgeType.Failure; // foreach (string error in SurveyInfo.ValidationErrors) // response.Message += error + Environment.NewLine; // return response; //} } // Run within the context of a database transaction. Currently commented out. // The Decorator Design Pattern. //using (TransactionDecorator transaction = new TransactionDecorator()) { if (request.Action == "Create") { if (request.Criteria.FileInputStream == null) { Implementation.InsertSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); } else { // Excel string SurveyFile = Implementation.GetSurveyXml(request.Criteria.FileInputStream); SurveyInfo.XML = SurveyFile; Implementation.InsertSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); } } else if (request.Action == "Update") { if (request.Criteria.FileInputStream == null) { Implementation.UpdateSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); } else { // Excel string SurveyFile = Implementation.GetSurveyXml(request.Criteria.FileInputStream); SurveyInfo.XML = SurveyFile; Implementation.UpdateSurveyInfo(SurveyInfo); response.SurveyInfoList.Add(Mapper.ToDataTransferObject(SurveyInfo)); } } else if (request.Action == "Delete") { var criteria = request.Criteria as SurveyInfoCriteria; var survey = Implementation.GetSurveyInfoById(SurveyInfo.SurveyId); try { if (Implementation.DeleteSurveyInfo(survey)) { response.RowsAffected = 1; } else { response.RowsAffected = 0; } } catch { response.RowsAffected = 0; } } } 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); } }