示例#1
0
        public bool Create(Reserva obj)
        {
            try
            {
                bool aptoParaReserva = true;
                obj.fechaHora = DateTime.Now;
                List<Reserva> listilla = DReserva.Instancia.SelectReservaByCanchaAndFecha(obj.fecha, obj.idCancha);
                foreach (var item in listilla)
                {
                    if (obj.horaInicio >= item.horaInicio && obj.horaFin <= item.horaFin)
                    {
                        aptoParaReserva = false;
                        break;
                    }
                }

                if (aptoParaReserva)
                {
                    return DReserva.Instancia.Create(obj);
                }
                else
                {
                    return false;
                }

            }
            catch (Exception)
            {
                return false;
            }
        }
示例#2
0
 public bool Create(Reserva obj)
 {
     try
     {
         db.Reserva.Add(obj);
         db.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
示例#3
0
        public bool Edit(Reserva obj)
        {
            try
            {
                bool aptoParaReserva = true;

                List<Reserva> listilla = DReserva.Instancia.SelectReservaByCanchaAndFecha(obj.fechaHora, obj.idCancha);
                foreach (var item in listilla)
                {
                    if (item.horaInicio == obj.horaInicio)
                    {
                        aptoParaReserva = false;
                        break;
                    }
                    if (item.horaFin == obj.horaFin)
                    {
                        aptoParaReserva = false;
                        break;
                    }
                }

                if (aptoParaReserva)
                {
                    return DReserva.Instancia.Edit(obj);
                }
                else
                {
                    return false;
                }

            }
            catch (Exception)
            {
                return false;
            }
        }
示例#4
0
        public bool registrarReserva(string fecha, int idUsuario, int idCancha, string[] horaInicio, string[] horaFin)
        {
            bool flag = false;

            for (int i = 0; i < horaInicio.Length; i++)
            {
                Reserva reserva = new Reserva();
                reserva.fecha = Convert.ToDateTime(fecha);
                reserva.idUsuario = idUsuario;
                reserva.idCancha = idCancha;

                TimeSpan horaInicio2 = DateTime.ParseExact(horaInicio[i], "HH", CultureInfo.InvariantCulture).TimeOfDay;
                TimeSpan horaFin2 = DateTime.ParseExact(horaFin[i], "HH", CultureInfo.InvariantCulture).TimeOfDay;
                reserva.horaInicio = horaInicio2;
                reserva.horaFin = horaFin2;
                reserva.activo = true;

                if (NReserva.Instancia.Create(reserva))
                {
                    flag = true;
                }
            }

            if (flag)
                return true;
            else
                return false;
        }
示例#5
0
 public bool Edit(Reserva objReserva)
 {
     Reserva obj = db.Reserva.Find(objReserva.id);
     obj.id = objReserva.id;
     obj.fechaHora = objReserva.fechaHora;
     obj.idUsuario = objReserva.idUsuario;
     obj.idCancha = objReserva.idCancha;
     obj.activo = objReserva.activo;
     try
     {
         db.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }