Esempio n. 1
0
        public async Task <List <AvailableSonyDTO> > GetAvailableSonys()
        {
            var result = await _client.Cypher.Match(@"(sony:Sony)<-[r:OWN]-(renterer:Renterer)")
                         .Return((renterer, sony) => new
            {
                Renterer = renterer.As <Renterer>(),
                Sony     = sony.As <Sony>()
            })
                         .ResultsAsync;

            List <AvailableSonyDTO> list = new List <AvailableSonyDTO>();

            foreach (var indeks in result)
            {
                AvailableSonyDTO rdto = new AvailableSonyDTO();
                rdto.Sony             = indeks.Sony;
                rdto.UsernameRenterer = indeks.Renterer.Username;
                list.Add(rdto);
            }
            List <AvailableSonyDTO> rentedSonyList = await this.GetAllReserved();

            List <AvailableSonyDTO> avalSony = new List <AvailableSonyDTO>();
            bool helpFlag;

            list.ForEach(el =>
            {
                helpFlag = false;
                rentedSonyList.ForEach(e =>
                {
                    if (el.Sony.SerialNumber == e.Sony.SerialNumber)
                    {
                        helpFlag = true;
                    }
                });
                if (helpFlag == false)
                {
                    avalSony.Add(el);
                }
            });
            return(avalSony);
        }
Esempio n. 2
0
        public async Task <List <AvailableSonyDTO> > GetAllReserved()
        {
            var result = await _client.Cypher.Match(@"(renterer:Renterer) -[r:OWN]->(sony:Sony) - [rel:RESERVED_BY] ->(rentee:Rentee)")
                         .Return((sony, renterer) => new
            {
                Sony     = sony.As <Sony>(),
                Renterer = renterer.As <Rentee>()
            })
                         .ResultsAsync;

            List <AvailableSonyDTO> list = new List <AvailableSonyDTO>();

            foreach (var indeks in result)
            {
                AvailableSonyDTO rdto = new AvailableSonyDTO();
                rdto.UsernameRenterer = indeks.Renterer.Username;
                rdto.Sony             = indeks.Sony;
                list.Add(rdto);
            }
            return(list);
        }