예제 #1
0
        //public. Хочу спать.
        public Reserve(Client client, Bike bike, DateTime endTime)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            if (bike == null)
            {
                throw new ArgumentNullException(nameof(bike));
            }

            if (endTime == null)
            {
                throw new ArgumentNullException(nameof(endTime));
            }


            Client          = client;
            Bike            = bike;
            Bike.IsReserved = true;
            EndTime         = endTime;
            StartDate       = DateTime.UtcNow;
            Status          = ReserveStatus.Wait;
        }
        public int GetCountResUser(int id, string FullNameEquipment, DateTime?date, int status)
        {
            ReserveStatus reserveStatus = (ReserveStatus)status;
            string        nameEquipment = "";

            if (!string.IsNullOrWhiteSpace(FullNameEquipment))
            {
                nameEquipment = FullNameEquipment;
            }
            var result = _context.Reservations
                         .Include(c => c.User)
                         .Include(e => e.Equipment)
                         .Include(s => s.Schedule);

            var countResult = date.HasValue ?
                              (
                result.Where(x => x.UserId.Equals(id) &&
                             x.Equipment.Name.Contains(nameEquipment) &&
                             x.Date.Equals(date) &&
                             x.Status.Equals(reserveStatus))
                .Count()
                              ) : (

                result.Where(x => x.UserId.Equals(id) &&
                             x.Equipment.Name.Contains(nameEquipment) &&
                             x.Status.Equals(reserveStatus))
                .Count()
                );

            return(countResult);
        }
예제 #3
0
 void Start()
 {
     _status  = ReserveStatus.unpicked;
     interact = gameObject.GetComponentInParent <ReserveController>().Interact.GetComponent <InteractController>();
     interact.HideArea();
     this.gameObject.AddComponent <BoxCollider>();
 }
예제 #4
0
    private void Update()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit) && hit.collider.gameObject == this.gameObject)
        {
            if (_status == ReserveStatus.unpicked)
            {
                _status = ReserveStatus.mouseOn;
                interact.ShowArea();
            }
        }
        else
        {
            _status = ReserveStatus.unpicked;
            interact.HideArea();
        }
    }
        public async Task <List <Reserver> > FindWithPagedSearch(
            string FullNameUser,
            string FullNameEquipment,
            int size, int offset,
            DateTime?date,
            int status)
        {
            IQueryable <Reserver> result = _context.Reservations
                                           .Include(c => c.User)
                                           .Include(e => e.Equipment)
                                           .Include(s => s.Schedule);

            ReserveStatus reserveStatus = (ReserveStatus)status;

            if (!string.IsNullOrWhiteSpace(FullNameUser) &&
                !string.IsNullOrWhiteSpace(FullNameEquipment) &&
                date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.User.FullName.Contains(FullNameUser) && x.Equipment.Name.Contains(FullNameEquipment) && x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }


            else if (!string.IsNullOrWhiteSpace(FullNameUser) &&
                     string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     date.HasValue &&
                     status != 0)
            {
                result = result.Where(x => x.User.FullName.Contains(FullNameUser) && x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }

            else if (
                string.IsNullOrWhiteSpace(FullNameUser) &&
                !string.IsNullOrWhiteSpace(FullNameEquipment) &&
                date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.Equipment.Name.Contains(FullNameEquipment) && x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }

            else if (string.IsNullOrWhiteSpace(FullNameUser) &&
                     string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     date.HasValue &&
                     status != 0)
            {
                result = result.Where(x => x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }

            else if (string.IsNullOrWhiteSpace(FullNameUser) &&
                     string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     !date.HasValue &&
                     status != 0)
            {
                result = result.Where(x => x.Status.Equals(reserveStatus));
            }

            else if (!string.IsNullOrWhiteSpace(FullNameUser) &&
                     string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     !date.HasValue &&
                     status != 0)
            {
                result = result.Where(x => x.Status.Equals(reserveStatus));
            }
            else if (string.IsNullOrWhiteSpace(FullNameUser) &&
                     !string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     !date.HasValue &&
                     status != 0)
            {
                result = result.Where(x => x.Status.Equals(reserveStatus));
            }

            else if (string.IsNullOrWhiteSpace(FullNameUser) &&
                     !string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     !date.HasValue &&
                     status == 0)
            {
                result = result.Where(x => x.Status.Equals(reserveStatus));
            }
            else if (!string.IsNullOrWhiteSpace(FullNameUser) &&
                     string.IsNullOrWhiteSpace(FullNameEquipment) &&
                     !date.HasValue &&
                     status == 0)
            {
                result = result.Where(x => x.Status.Equals(reserveStatus));
            }

            result = result.OrderBy(d => d.Date).ThenBy(h => h.Schedule.HourInitial).Skip(offset).Take(size);

            return(await result.ToListAsync());
        }
        /*
         * Validate if the equipment has the available time or not
         */
        public async Task <bool> IsValidationAsync(int equipId, int schedId, DateTime date, ReserveStatus status)
        {
            var validate = _context.Reservations
                           .Where(s => s.ScheduleId.Equals(schedId) &&
                                  s.Status.Equals(status) &&
                                  s.EquipmentId.Equals(equipId) &&
                                  s.Date.Equals(date));

            return(await validate.AnyAsync());
        }
        public async Task <List <Reserver> > FindWithPagedSearchForUser(

            int id,
            string equipment,
            int size,
            int offset,
            DateTime?date,
            int status)
        {
            ReserveStatus reserveStatus = (ReserveStatus)status;

            IQueryable <Reserver> result = _context.Reservations
                                           .Include(c => c.User)
                                           .Include(e => e.Equipment)
                                           .Include(s => s.Schedule);

            //List reservations with  date, equipment and status;
            if (
                !string.IsNullOrWhiteSpace(equipment) &&
                date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Equipment.Name.Contains(equipment) && x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }

            //List reservations with  date and status;
            else if (
                string.IsNullOrWhiteSpace(equipment) &&
                date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Date.Equals(date) && x.Status.Equals(reserveStatus));
            }

            //List reservations with equipments and status;
            else if (
                !string.IsNullOrWhiteSpace(equipment) &&
                !date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Equipment.Name.Contains(equipment) && x.Status.Equals(reserveStatus));
            }

            //List reservations only with status
            else if (
                string.IsNullOrWhiteSpace(equipment) &&
                !date.HasValue &&
                status != 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Status.Equals(reserveStatus));
            }

            //List reservations only with equipments;
            else if (
                !string.IsNullOrWhiteSpace(equipment) &&
                !date.HasValue &&
                status == 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Equipment.Name.Contains(equipment));
            }

            //List reservations only with date;
            else if (
                string.IsNullOrWhiteSpace(equipment) &&
                date.HasValue &&
                status == 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Date.Equals(date));
            }

            //List reservations with equipment and date;
            else if (
                !string.IsNullOrWhiteSpace(equipment) &&
                date.HasValue &&
                status == 0)
            {
                result = result.Where(x => x.UserId.Equals(id) && x.Equipment.Name.Contains(equipment) && x.Date.Equals(date));
            }

            //List all reservations of user;
            else
            {
                result = result.Where(x => x.UserId.Equals(id));
            }
            result = result.OrderBy(d => d.Date).ThenBy(h => h.Schedule.HourInitial).Skip(offset).Take(size);
            return(await result.ToListAsync());
        }
예제 #8
0
 public void ExpireReserve()
 {
     Status          = ReserveStatus.Failed;
     Bike.IsReserved = false;
 }
예제 #9
0
 public void EndReserve()
 {
     Status          = ReserveStatus.SuccessEnded;
     Bike.IsReserved = false;
     EndTime         = DateTime.UtcNow;
 }