示例#1
0
        public CriminalServiceResponse DeleteCriminals(List <CriminalInfo> criminalList)
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            if (criminalList == null)
            {
                response = getFailedResponse();
                response.ServiceErrorMsg = Defs.ERROR_PARAMETER_CONTAINS_NULL;
            }
            else
            {
                try
                {
                    if (DataProcressingService.DeleteCriminals(Util.ConvertCriminalCriminalInfo(criminalList)))
                    {
                        response           = getSuccessResponse();
                        response.criminals = criminalList;
                    }
                    else
                    {
                        response = getFailedResponse();
                        response.ServiceErrorMsg = Defs.ERROR_DELETE_OPERATION_IS_FAILED;
                    }
                }
                catch (Exception e)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
                }
            }
            return(response);
        }
示例#2
0
        public CriminalServiceResponse SearchCriminals(CriminalSearchCriteria searchCriteria)
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            if (searchCriteria == null)
            {
                return(GetCriminals());
            }
            else
            {
                try
                {
                    List <CriminalInfo> criminalInfoList = DataProcressingService.SearchCriminals(searchCriteria);
                    if (criminalInfoList == null || criminalInfoList.Count <= 0)
                    {
                        response = getFailedResponse();
                        response.ServiceErrorMsg = Defs.ERROR_DATA_NOT_FOUND;
                    }
                    else
                    {
                        response           = getSuccessResponse();
                        response.criminals = criminalInfoList;
                    }
                }
                catch (Exception e)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
                }
            }
            return(response);
        }
示例#3
0
        public CriminalServiceResponse DeleteCriminal(long id)
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            if (id <= 0)
            {
                response = getFailedResponse();
                response.ServiceErrorMsg = Defs.ERROR_PARAMETER_CONTAINS_NULL;
            }
            else
            {
                try
                {
                    if (DataProcressingService.DeleteCriminal(id))
                    {
                        response           = getSuccessResponse();
                        response.criminals = GetCriminal(id).criminals;
                    }
                    else
                    {
                        response = getFailedResponse();
                        response.ServiceErrorMsg = Defs.ERROR_DELETE_OPERATION_IS_FAILED;
                    }
                }
                catch (Exception e)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
                }
            }
            return(response);
        }
示例#4
0
        public CriminalServiceResponse QuickSearchCriminalsByName(String searchCriteria)
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            if (searchCriteria == null || searchCriteria.Equals(String.Empty))
            {
                return(GetCriminals());
            }
            else
            {
                try
                {
                    List <CriminalInfo> criminalDetail = DataProcressingService.GetSelectedCriminal(searchCriteria);
                    if (criminalDetail != null)
                    {
                        response           = getSuccessResponse();
                        response.criminals = criminalDetail;
                    }
                    else
                    {
                        response = getFailedResponse();
                        response.ServiceErrorMsg = Defs.ERROR_OPERATION_IS_FAILED;
                    }
                }
                catch (Exception e)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
                }
            }
            return(response);
        }
示例#5
0
        public CriminalServiceResponse GetCriminals()
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            try
            {
                List <CriminalInfo> criminalList = DataProcressingService.GetCriminals();
                if (criminalList == null)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATA_NOT_FOUND;
                }
                else
                {
                    response           = getSuccessResponse();
                    response.criminals = criminalList;
                }
            }
            catch (Exception e)
            {
                response = getFailedResponse();
                response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
            }
            return(response);
        }
示例#6
0
        public CriminalServiceResponse GetCriminal(long id)
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            if (id == 0)
            {
                response = getFailedResponse();
                response.ServiceErrorMsg = Defs.ERROR_PARAMETER_CONTAINS_NULL;
            }
            else
            {
                try
                {
                    CriminalInfo criminalDetail = DataProcressingService.GetSelectedCriminal(id);
                    if (criminalDetail != null)
                    {
                        response           = getSuccessResponse();
                        response.criminals = new List <CriminalInfo>();
                        response.criminals.Add(criminalDetail);
                    }
                    else
                    {
                        response = getFailedResponse();
                        response.ServiceErrorMsg = Defs.ERROR_OPERATION_IS_FAILED;
                    }
                }
                catch (Exception e)
                {
                    response = getFailedResponse();
                    response.ServiceErrorMsg = Defs.ERROR_DATABASE_IS_DOWN;
                }
            }
            return(response);
        }
示例#7
0
        private CriminalServiceResponse getFailedResponse()
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            response.criminals       = null;
            response.operationStatus = false;

            return(response);
        }
示例#8
0
        private CriminalServiceResponse getSuccessResponse()
        {
            CriminalServiceResponse response = new CriminalServiceResponse();

            response.ServiceErrorMsg = null;
            response.operationStatus = true;

            return(response);
        }