Esempio n. 1
0
        public async Task <JsonResult> Get(string koderayon, string namarayon, string kodearea, string namaarea, string kodewil, string namawilayah)
        {
            var watch = Stopwatch.StartNew();

            try
            {
                var param = new MasterRayonDto()
                {
                    KodeRayon   = koderayon,
                    NamaRayon   = namarayon,
                    KodeArea    = kodearea,
                    NamaArea    = namaarea,
                    KodeWil     = kodewil,
                    NamaWilayah = namawilayah,
                };

                AppResponse.ResponseGetData(await rayonService.GetAll(param));
            }
            catch (Exception e)
            {
                AppResponse.ResponseErrorGetData(e.InnerException != null ? e.InnerException.Message : e.Message);
            }

            watch.Stop();
            AppResponse._result.execution_time = watch.ElapsedMilliseconds;
            return(new JsonResult(AppResponse._result));
        }
        public async Task <IEnumerable <MasterRayonDto> > GetAllAsync(MasterRayonDto param)
        {
            using var context = new AppDbContext();

            IQueryable <MasterRayon> query = context.MasterRayon;


            if (!string.IsNullOrWhiteSpace(param.KodeRayon))
            {
                query = query.Where(n => n.KodeRayon == param.KodeRayon);
            }

            if (!string.IsNullOrWhiteSpace(param.NamaRayon))
            {
                query = query.Where(n => EF.Functions.Like(n.NamaRayon, $"%{param.NamaRayon}%"));
            }

            if (!string.IsNullOrWhiteSpace(param.KodeArea))
            {
                query = query.Where(n => n.KodeArea == param.KodeArea);
            }

            if (!string.IsNullOrWhiteSpace(param.NamaArea))
            {
                query = query.Where(n => EF.Functions.Like(n.NamaArea, $"%{param.NamaArea}%"));
            }

            if (!string.IsNullOrWhiteSpace(param.KodeWil))
            {
                query = query.Where(n => n.KodeWil == param.KodeWil);
            }

            if (!string.IsNullOrWhiteSpace(param.NamaWilayah))
            {
                query = query.Where(n => EF.Functions.Like(n.NamaWilayah, $"%{param.NamaWilayah}%"));
            }


            var data = await query.ToListAsync();

            return(_mapper.Map <IEnumerable <MasterRayonDto> >(data));
        }
Esempio n. 3
0
 public async Task <IEnumerable <MasterRayonDto> > GetAll(MasterRayonDto param)
 {
     return(await rayon.GetAllAsync(param));
 }