コード例 #1
0
        public static void InsertarHabitacion(Habitacion habitacion)
        {
            TransactionResult result = HabitacionMapper.Insert(habitacion);

            if (!result.IsOk)
            {
                throw new ErrorServidorException(result.Error);
            }
        }
コード例 #2
0
        public int IngresarHabitacion(Habitacion habitacion)
        {
            var minimo = int.Parse(ConfigurationSettings.AppSettings["PrecioMinimo"]);

            if (habitacion.Precio <= minimo)
            {
                throw new ReservasException("El precio debe ser superior a " + minimo.ToString());
            }
            if (habitacion.CantidadPlazas <= 0)
            {
                throw new ReservasException("La cantidad de plaza debe ser mayor que 0");
            }
            TransactionResult resultado = HabitacionMapper.Insert(habitacion);

            if (resultado.IsOk)
            {
                HabitacionesCache();
                return(resultado.Id);
            }
            else
            {
                throw new ReservasException(resultado.Error);
            }
        }