Пример #1
0
        public async Task <IActionResult> GetAllServiceQuestionsByServiceType([FromQuery] ServiceQuestionParameters serviceQuestionParameters)
        {
            var getServiceQuestionByServiceTypeQuery = new GetAllServiceQuestionByServiceTypeQuery(serviceQuestionParameters);
            var result = await mediator.Send(getServiceQuestionByServiceTypeQuery);

            return(StatusCode((int)result.Code, result.Value));
        }
Пример #2
0
        public async Task <APIResponse> GetAllServiceQuestionsByServiceType(ServiceQuestionParameters serviceQuestionParameters)
        {
            try
            {
                var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Vendor + VendorServiceOperation.GetAllServiceQuestionsByServiceType());
                url.Query = QueryStringHelper.ConvertToQueryString(serviceQuestionParameters);

                var response = await client.GetAsync(url.ToString());

                if (response.IsSuccessStatusCode)
                {
                    var serviceQuestion = JsonConvert.DeserializeObject <List <ServiceQuestionDetailsResponse> >(await response.Content.ReadAsStringAsync());
                    return(new APIResponse(serviceQuestion, HttpStatusCode.OK));
                }
                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetAllServiceQuestionsByServiceType()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
Пример #3
0
        /// <summary>
        /// Gets all service question by service type identifier.
        /// </summary>
        /// <param name="serviceQuestionParameters"></param>
        /// <returns></returns>

        /* public async Task<PagedList<Entity>> GetAllServiceQuestionByServiceTypeId(ServiceQuestionParameters serviceQuestionParameters)
         * {
         *    var getServiceQuestionParameters = new object[] {
         *        new MySqlParameter("@p_Limit", serviceQuestionParameters.PageSize),
         *        new MySqlParameter("@p_Offset", (serviceQuestionParameters.PageNumber - 1) * serviceQuestionParameters.PageSize),
         *        new MySqlParameter("@p_Value", serviceQuestionParameters.Value),
         *        new MySqlParameter("@p_IsForSingleData", false),
         *        new MySqlParameter("@p_IsForServiceType", true),
         *        new MySqlParameter("@p_VendorLeadId", serviceQuestionParameters.VendorLeadId),
         *        new MySqlParameter("@p_IsForVendor", serviceQuestionParameters.IsForVendor),
         *        new MySqlParameter("@p_FromDate", serviceQuestionParameters.FromDate),
         *        new MySqlParameter("@p_ToDate", serviceQuestionParameters.ToDate)
         *    };
         *
         *    var servicequestions = await FindAll("CALL SpSelectSearchServiceQuestion(@p_Limit, @p_Offset, @p_Value, @p_IsForSingleData,@p_IsForServiceType,@p_VendorLeadId,@p_IsForVendor, @p_FromDate, @p_ToDate)", getServiceQuestionParameters).ToListAsync();
         *
         *    var mappedservicequestions = servicequestions.AsQueryable().ProjectTo<ServiceQuestionResponse>(mapper.ConfigurationProvider);
         *    var sortedservicequestions = sortHelper.ApplySort(mappedservicequestions, serviceQuestionParameters.OrderBy);
         *    var shapedservicequestions = dataShaper.ShapeData(sortedservicequestions, serviceQuestionParameters.Fields);
         *
         *    return await PagedList<Entity>.ToPagedList(shapedservicequestions, serviceQuestionParameters.PageNumber, serviceQuestionParameters.PageSize);
         * }   */

        public async Task <IEnumerable <ServiceQuestionDetailsResponse> > GetAllServiceQuestionByServiceTypeId(ServiceQuestionParameters serviceQuestionParameters)
        {
            var serviceQuestions = FindByCondition(servicequestion => servicequestion.Active == Convert.ToInt16(true)).OrderBy(x => x.ServiceType)
                                   .ProjectTo <ServiceQuestionDetailsResponse>(mapper.ConfigurationProvider);

            SearchByVendorLeadId(ref serviceQuestions, serviceQuestionParameters);
            var result = await serviceQuestions.ToListAsync();

            return(result);
        }
Пример #4
0
 private void SearchByVendorLeadId(ref IQueryable <ServiceQuestionDetailsResponse> serviceQuestions, ServiceQuestionParameters serviceQuestionParameters)
 {
     if (serviceQuestionParameters.Value > 0)
     {
         if (serviceQuestionParameters.IsForVendor == true)
         {
             serviceQuestions = serviceQuestions.Where(x => x.ServiceType.Equals(serviceQuestionParameters.Value) && x.IsForVendor.Equals(Convert.ToInt16(serviceQuestionParameters.IsForVendor))).OrderBy(x => x.ServiceType);
         }
         else
         {
             serviceQuestions = serviceQuestions.Where(x => x.ServiceType.Equals(serviceQuestionParameters.Value) && x.IsForVendor.Equals(Convert.ToInt16(serviceQuestionParameters.IsForVendor))).OrderBy(x => x.ServiceType);
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetAllServiceQuestionByServiceTypeQuery"/> class.
 /// </summary>
 /// <param name="serviceTypeId">The service type identifier.</param>
 public GetAllServiceQuestionByServiceTypeQuery(ServiceQuestionParameters serviceQuestionParameters)
 {
     this.serviceQuestionParameters = serviceQuestionParameters;
 }
        public async Task <IActionResult> GetAllServiceQuestionsByServiceType([FromQuery] ServiceQuestionParameters serviceQuestionParameters)
        {
            var result = await serviceQuestionService.GetAllServiceQuestionsByServiceType(serviceQuestionParameters);

            return(StatusCode((int)result.Code, result.Value));
        }