Example #1
0
        public List <SharedModels.Reports> Get(ReportsSearch obj)
        {
            var query = db.Reports.Include(x => x.Prilozi).AsQueryable();

            if (!String.IsNullOrWhiteSpace(obj.Naslov))
            {
                query = query.Where(x => x.Naslov.Contains(obj.Naslov));
            }
            if (obj.Datum != null)
            {
                query = query.Where(x => x.DatumKreiranja.Date == obj.Datum.GetValueOrDefault().Date);
            }

            var rezultat = query.ToList();
            var povratni = mapko.Map <List <Reports> >(rezultat);

            foreach (var i in povratni)
            {
                foreach (var j in i.Prilozi)
                {
                    Fajl fajl = GetFajl(j);
                    i.RawPrilozi.Add(fajl);
                }
            }
            return(povratni);
        }
        private async void btnDobavi_Click(object sender, EventArgs e)
        {
            _apiServis = new APIService("reports");

            ReportsSearch req = new ReportsSearch {
                Naslov = txtNaziv.Text,
                Datum  = dTPDatum.Value
            };

            if (chkZanemari.Checked)
            {
                req.Datum = null;
            }
            _reportsLista = await _apiServis.GetAll <PagedResponse <Reports> >(req);

            RegulisiDataSource();
        }
Example #3
0
        private PagedResponse <Reports> GetPagedResponse(ReportsSearch obj)
        {
            var listaObjava = reportsService.Get(obj);
            PagedResponse <Reports> respons = new PagedResponse <Reports>();

            respons.TotalPageCount = (int)Math.Ceiling((double)listaObjava.Count() / (double)obj.Limit);
            respons.Stavke         = listaObjava.Skip((obj.Page - 1) * obj.Limit).Take(obj.Limit).ToList();

            ReportsSearch iducaKlon = obj.Clone() as ReportsSearch;

            iducaKlon.Page = (iducaKlon.Page + 1) > respons.TotalPageCount ? -1 : iducaKlon.Page + 1;
            String iduciUrl = iducaKlon.Page == -1 ? null : this.Url.Action("Get", null, iducaKlon, Request.Scheme);

            ReportsSearch proslaKlon = obj.Clone() as ReportsSearch;

            proslaKlon.Page = (proslaKlon.Page - 1) < 0 ? -1 : proslaKlon.Page - 1;
            String prosliUrl = proslaKlon.Page == -1 ? null : this.Url.Action("Get", null, proslaKlon, Request.Scheme);

            respons.IducaStranica  = !String.IsNullOrWhiteSpace(iduciUrl) ? new Uri(iduciUrl) : null;
            respons.ProslaStranica = !String.IsNullOrWhiteSpace(prosliUrl) ? new Uri(prosliUrl) : null;
            return(respons);
        }
Example #4
0
        public PagedResponse <Reports> Get([FromQuery] ReportsSearch obj)
        {
            var rezult = GetPagedResponse(obj);

            return(rezult);
        }