コード例 #1
0
        public IActionResult Filter([FromBody] Filter filter)
        {
            SmestajProvider provider = new SmestajProvider();

            List <SmestajView> fsm = new List <SmestajView>();

            if (filter.C_min > 0 || filter.C_max > 0)
            {
                fsm = provider.FilterCena(filter.idDest, filter.C_min, filter.C_max);
            }

            if (filter.D_od != null || filter.D_do != null)
            {
                DateTime D_od = DateTime.Parse(filter.D_od);
                DateTime D_do = DateTime.Parse(filter.D_do);
                if (filter.D_od == null)
                {
                    D_od = new DateTime(2019, 1, 1);
                }
                if (filter.D_do == null)
                {
                    D_do = new DateTime(2119, 1, 1);
                }

                TerminiProvider tp = new TerminiProvider();

                List <SmestajView> sm   = provider.VratiS(filter.idDest);
                List <SmestajView> fsmD = new List <SmestajView>();
                foreach (SmestajView smes in sm)
                {
                    bool ima = tp.FilterDatum(smes.Id, D_od, D_do);
                    if (ima)
                    {
                        fsmD.Add(smes);
                    }
                }

                foreach (SmestajView smes in fsmD)
                {
                    if (!fsm.Contains(smes))
                    {
                        fsm.Add(smes);
                    }
                }
            }

            if (fsm == null)
            {
                return(NotFound());
            }
            var json = JsonConvert.SerializeObject(fsm, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            });

            return(Ok(json));
        }
コード例 #2
0
        public IActionResult VratiS(int id)
        {
            SmestajProvider    provider = new SmestajProvider();
            List <SmestajView> s        = provider.VratiS(id);

            if (s == null)
            {
                return(NotFound());
            }
            var json = JsonConvert.SerializeObject(s, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            });

            return(Ok(json));
        }