Beispiel #1
0
        public async Task <APIResponse> GetAllServices(ServicesParameters serviceParameters)
        {
            try
            {
                var client = httpClientFactory.CreateClient(VendorServiceOperation.serviceName);

                UriBuilder url = new UriBuilder(servicesConfig.Vendor + VendorServiceOperation.GetAllServices());
                url.Query = QueryStringHelper.ConvertToQueryString(serviceParameters);

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

                if (response.IsSuccessStatusCode)
                {
                    var branch = JsonConvert.DeserializeObject <List <ServiceDetailsResponse> >(await response.Content.ReadAsStringAsync());
                    foreach (var item1 in branch)
                    {
                        byte[] b = System.IO.File.ReadAllBytes(item1.PhotoPath);
                        item1.PhotoPath = Convert.ToBase64String(b);
                    }

                    return(new APIResponse(branch, HttpStatusCode.OK));
                }

                return(new APIResponse(response.StatusCode));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception in method 'GetAllBranches()'");
                var exMessage = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                return(new APIResponse(exMessage, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IActionResult> GetAllServices([FromQuery] ServicesParameters serviceParameters)
        {
            var getAllServicesQuery = new GetAllServicesQuery(serviceParameters);
            var result = await mediator.Send(getAllServicesQuery);

            //if (result.Code == HttpStatusCode.OK)
            //{
            //    Response.Headers.Add("X-Pagination", PagedList<Entity>.ToJson(result.Value as PagedList<Entity>));
            //}

            return(StatusCode((int)result.Code, result.Value));
        }
Beispiel #3
0
        /// <summary>
        /// Gets all services.
        /// </summary>
        /// <param name="serviceParameters">The service parameters.</param>
        /// <returns></returns>
        //public async Task<PagedList<Entity>> GetAllServices(ServicesParameters serviceParameters)
        //{
        //    var getStoriesParams = new object[] {
        //        new MySqlParameter("@p_limit", serviceParameters.PageSize),
        //        new MySqlParameter("@p_offset", (serviceParameters.PageNumber - 1) * serviceParameters.PageSize),
        //        new MySqlParameter("@p_searchKeyword", serviceParameters.SearchKeyword),
        //          new MySqlParameter("@p_Value", serviceParameters.Value),
        //        new MySqlParameter("@p_fromDate", serviceParameters.FromDate),
        //        new MySqlParameter("@p_toDate", serviceParameters.ToDate)
        //    };
        //    var services = await FindAll("CALL SpSelectActiveService(@p_limit, @p_offset, @p_searchKeyword,@p_Value @p_fromDate, @p_toDate)", getStoriesParams).ToListAsync();


        //    var mappedServices = services.AsQueryable().ProjectTo<ServiceResponse>(mapper.ConfigurationProvider);
        //    var sortedServices = sortHelper.ApplySort(mappedServices, serviceParameters.OrderBy);
        //    var shapedServices = dataShaper.ShapeData(sortedServices, serviceParameters.Fields);

        //    return await PagedList<Entity>.ToPagedList(shapedServices, serviceParameters.PageNumber, serviceParameters.PageSize);
        //}

        public async Task <List <ServiceResposnseList> > GetAllServices(ServicesParameters serviceParameters)
        {
            var services = FindByCondition(ss => ss.Active == Convert.ToInt16(true)).ProjectTo <ServiceResposnseList>(mapper.ConfigurationProvider);

            SearchServicesByVendorId(ref services, serviceParameters);

            // FilterByDate(ref wallets, walletsParameter.FromDate, walletsParameter.ToDate);
            //var sortedWallets = sortHelper.ApplySort(services, serviceParameters.OrderBy);
            //var pagedWallets = sortedWallets
            //                   .Skip((serviceParameters.PageNumber - 1) * serviceParameters.PageSize)
            //                   .Take(serviceParameters.PageSize);

            var result = await services.ToListAsync();

            return(result);
        }
Beispiel #4
0
 private void SearchServicesByVendorId(ref IQueryable <ServiceResposnseList> services, ServicesParameters serviceParameters)
 {
     if (serviceParameters.Value != null)
     {
         services = services.Where(ss => ss.VendorId.Equals(serviceParameters.Value) || ss.VendorName.Equals(serviceParameters.Value));
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetAllServicesQuery"/> class.
 /// </summary>
 /// <param name="serviceParameters">The service parameters.</param>
 public GetAllServicesQuery(ServicesParameters servicesParameters)
 {
     this.servicesParameters = servicesParameters;
 }