public async Task <IEnumerable <MasterCabangDto> > GetAllAsync(MasterCabangDto param)
        {
            using var context = new AppDbContext();

            IQueryable <MasterCabang> query = context.MasterCabang;

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

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

            var data = await query.ToListAsync();

            return(_mapper.Map <IEnumerable <MasterCabangDto> >(data));
        }
Beispiel #2
0
        public async Task <JsonResult> Get(string kodecabang, string namacabang)
        {
            var watch = Stopwatch.StartNew();

            try
            {
                var param = new MasterCabangDto()
                {
                    KodeCabang = kodecabang,
                    NamaCabang = namacabang
                };

                AppResponse.ResponseGetData(await cabangService.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 <MasterCabangDto> > GetAll(MasterCabangDto param)
 {
     return(await cabang.GetAllAsync(param));
 }