예제 #1
0
        public int GetIncomeBoatRentalsByWeekAndBoat(int week, int id)
        {
            DateTimeFormatInfo dfi      = DateTimeFormatInfo.CurrentInfo;
            Calendar           calendar = dfi.Calendar;

            var linqQuery = from row in dbc.BoatRentals where row.FKRentedBoat.BoatId.Equals(id) select row;
            List <BoatRentalsEntity> BoatRentalsList = linqQuery.ToList();
            int RentalCount = 0;
            int Income      = 0;

            for (int i = 0; i < BoatRentalsList.Count; i++)
            {
                if (calendar.GetWeekOfYear(BoatRentalsList[i].StartingDate, dfi.CalendarWeekRule, DayOfWeek.Monday)
                    .Equals(week))
                {
                    List <BoatRentalsEntity> BoatRentalsList2 = linqQuery.ToList();
                    BoatsDaoImpl             boatsDaoImpl     = new BoatsDaoImpl();
                    BoatsEntity boatsEntity = boatsDaoImpl.GetBoatsById(id);


                    for (int g = 0; g < BoatRentalsList2.Count; g++)
                    {
                        Income += (BoatRentalsList[i].EndDate - BoatRentalsList[i].StartingDate).Days *
                                  Convert.ToInt32(boatsEntity.DailyPrice);
                    }
                }
            }
            return(Income);
        }
예제 #2
0
        public List <RentRequestsEntity> GetTemplateRentRequests()
        {
            Random random = new Random();
            List <RentRequestsEntity> TemplateRequests = new List <RentRequestsEntity>();

            for (int i = 0; i < 20; i++)
            {
                RentRequestsEntity req = new RentRequestsEntity();

                MembersDao           mem  = new MembersDaoImpl();
                List <MembersEntity> mems = mem.GetAllMembers();
                req.WhoBorrows = mems[random.Next(0, mems.Count)];

                BoatsDao           boat  = new BoatsDaoImpl();
                List <BoatsEntity> boats = boat.GetAllBoats();
                req.BoatToBorrow = boats[random.Next(0, boats.Count)];

                TransportDevicesDao           dev  = new TransportDevicesDaoImpl();
                List <TransportDevicesEntity> devs = dev.GetAllTransportDevices();
                req.DeviceToBorrow = devs[random.Next(0, devs.Count)]; // ez null is lehet
                req.BoatRentalsId  = generateID();

                req.EndDate                 = new DateTime(random.Next(2018, 2020), random.Next(1, 13), random.Next(1, 29));
                req.StartingDate            = new DateTime(2018, random.Next(1, 13), random.Next(1, 29));
                req.FromWhere               = "Innen";
                req.ToWhere                 = "Ide";
                req.Status                  = 3; // 1 - elfogadva, 2 - elutasitva, 3 - kerve/varakozas valaszra
                req.HowManyPersonWillTravel = 5;

                TemplateRequests.Add(req);
            }

            return(TemplateRequests);
        }
예제 #3
0
        public List <BoatRentalsEntity> GetTemplateBoatRents()
        {
            Random random = new Random();
            List <BoatRentalsEntity> TemplateBoatRentals = new List <BoatRentalsEntity>();
            int a = 500;

            for (int i = 0; i < a; i++)
            {
                BoatRentalsEntity TemplateBoatRental = new BoatRentalsEntity();
                TemplateBoatRental.BoatRentalsId           = generateID();
                TemplateBoatRental.FromWhere               = "Innen";
                TemplateBoatRental.ToWhere                 = "Ide";
                TemplateBoatRental.HowManyPersonWillTravel = 4;

                // FK's
                MembersDao           mem  = new MembersDaoImpl();
                List <MembersEntity> mems = mem.GetAllMembers();
                TemplateBoatRental.FKWhoRents = mems[random.Next(0, mems.Count)];

                BoatsDao           boat  = new BoatsDaoImpl();
                List <BoatsEntity> boats = boat.GetAllBoats();
                TemplateBoatRental.FKRentedBoat = boats[random.Next(0, boats.Count)];

                TransportDevicesDao           device  = new TransportDevicesDaoImpl();
                List <TransportDevicesEntity> devices = device.GetAllTransportDevices();
                TemplateBoatRental.FKRentedDevice = devices[random.Next(0, devices.Count)];

                TemplateBoatRentals.Add(TemplateBoatRental);
            }

            for (int i = 0; i < a; i++)
            {
                int temp  = random.Next(1, 12);
                int temp2 = random.Next(1, 12);
                int temp3 = temp2 + random.Next(1, 12);

                TemplateBoatRentals[i].StartingDate = new DateTime(2018, temp, temp2);
                TemplateBoatRentals[i].EndDate      = new DateTime(2018, temp, temp3);
            }



            return(TemplateBoatRentals);
        }
예제 #4
0
        public int GetIncomeBoatRentalsByMonthAndBoat(int month, int id)
        {
            var linqQuery = from row in dbc.BoatRentals
                            where (row.StartingDate.Month.Equals(month) & row.FKRentedBoat.BoatId.Equals(id))
                            select row;
            List <BoatRentalsEntity> BoatRentalsList = linqQuery.ToList();
            BoatsDaoImpl             boatsDaoImpl    = new BoatsDaoImpl();
            BoatsEntity boatsEntity = boatsDaoImpl.GetBoatsById(id);

            int Income = 0;

            for (int i = 0; i < BoatRentalsList.Count; i++)
            {
                Income += (BoatRentalsList[i].EndDate - BoatRentalsList[i].StartingDate).Days *
                          Convert.ToInt32(boatsEntity.DailyPrice);
            }

            return(Income);
        }