Example #1
0
        private long GetTotalRowsFilter(TourSearch valFilter)
        {
            long            vResult      = 0;
            DataTable       vDatainTable = new DataTable();
            SQLToolsLibrary vSqlTools    = new SQLToolsLibrary();

            try {
                if (valFilter.Categories == null)
                {
                    valFilter.Categories = new string[0];
                }
                List <SqlParameter> vParameterList = new List <SqlParameter> {
                    new SqlParameter("@IdLanguage", valFilter.IdLanguage.ToString()),
                    new SqlParameter("@IdCity", valFilter.IdCity.ToString()),
                    new SqlParameter("@IdCurrency", valFilter.IdCurrency.ToString()),
                    new SqlParameter("@Categories", valFilter.Categories.Length > 0 ? string.Join(",", valFilter.Categories) : null),
                    new SqlParameter("@MinPrice", valFilter.MinPrice),
                    new SqlParameter("@MaxPrice", valFilter.MaxPrice),
                    new SqlParameter("@MinDuration", valFilter.MinDuration),
                    new SqlParameter("@MaxDuration", valFilter.MaxDuration),
                    new SqlParameter("@MinScore", valFilter.MinScore),
                    new SqlParameter("@MaxScore", valFilter.MaxScore)
                };
                TourResponse vModel = new TourResponse();
                vDatainTable = vSqlTools.ExcecuteSelectWithStoreProcedure(vParameterList, "sp_Select_Tour_Filter_Total", vConnection);
                vResult      = DataTableToListFilterTotal(vDatainTable);
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
            }
            return(vResult);
        }
Example #2
0
        // POST: api/Tour
        public IHttpActionResult Post([FromBody] TourSearch valFilter)
        {
            string    vResult   = "3";
            ITourData vTourData = new TourData();

            try {
                bool vNullField = VerifyNullFiledsSearch(valFilter);

                if (vNullField)
                {
                    vResult = "1";
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, new { Code = HttpStatusCode.NotAcceptable, Message = Messages.vListContainNullValue, Result = vResult })));
                }
                string vResponse = vTourData.SelectByCity(valFilter);

                if (!string.IsNullOrEmpty(vResponse))
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, new { Code = HttpStatusCode.OK, Message = Messages.vOkListed, Result = vResponse })));
                }
                vResult = "2";
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, new { Code = HttpStatusCode.NoContent, Message = Messages.vNotListed, Result = vResult })));
            } catch (Exception) {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, new { Code = HttpStatusCode.BadRequest, Message = Messages.vInternalServerError, Result = vResult })));
            }
        }
Example #3
0
        private bool VerifyNullFiledsSearch(TourSearch valTourSearch)
        {
            bool vResult = false;

            if (valTourSearch.IdCity == Guid.Empty || valTourSearch.IdCity == null)
            {
                vResult = true;
                return(vResult);
            }
            if (valTourSearch.IdLanguage == Guid.Empty || valTourSearch.IdLanguage == null)
            {
                vResult = true;
                return(vResult);
            }
            if (valTourSearch.IdCurrency == Guid.Empty || valTourSearch.IdCurrency == null)
            {
                vResult = true;
                return(vResult);
            }
            return(vResult);
        }
Example #4
0
        public string SelectByCity(TourSearch valFilter)
        {
            string vResult = string.Empty;

            try {
                DataTable       vDatainTable = new DataTable();
                SQLToolsLibrary vSqlTools    = new SQLToolsLibrary();
                if (valFilter.Categories == null)
                {
                    valFilter.Categories = new string[0];
                }
                List <SqlParameter> vParameterList = new List <SqlParameter> {
                    new SqlParameter("@IdLanguage", valFilter.IdLanguage.ToString()),
                    new SqlParameter("@IdCity", valFilter.IdCity.ToString()),
                    new SqlParameter("@IdCurrency", valFilter.IdCurrency.ToString()),
                    new SqlParameter("@Categories", valFilter.Categories.Length > 0 ? string.Join(",", valFilter.Categories) : null),
                    new SqlParameter("@MinPrice", valFilter.MinPrice),
                    new SqlParameter("@MaxPrice", valFilter.MaxPrice),
                    new SqlParameter("@MinDuration", valFilter.MinDuration),
                    new SqlParameter("@MaxDuration", valFilter.MaxDuration),
                    new SqlParameter("@MinScore", valFilter.MinScore),
                    new SqlParameter("@MaxScore", valFilter.MaxScore),
                    new SqlParameter("@RowsPerPage", valFilter.RowsPerPage),
                    new SqlParameter("@PageNumber", valFilter.PageNumber)
                };
                TourResponse vModel = new TourResponse();
                vDatainTable = vSqlTools.ExcecuteSelectWithStoreProcedure(vParameterList, "sp_Select_Tour_Filter", vConnection);
                List <Tour> vDataTours = DataTableToListFilter(vDatainTable);
                vModel.Tours     = vDataTours;
                vModel.TotalRows = GetTotalRowsFilter(valFilter);
                if (vModel != null && vModel.Tours != null && vModel.Tours.Count > 0)
                {
                    vResult = JsonConvert.SerializeObject(vModel, Formatting.Indented);
                }
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
                vResult = string.Empty;
            }
            return(vResult);
        }