Beispiel #1
0
        public bool GuardarTipoReserva(CatTipoReserva Obj)
        {
            try
            {
                BDVideosUSAVEntitiesModelSolicitudes Model = new BDVideosUSAVEntitiesModelSolicitudes();


                var querybusca = from c in Model.CatTipoBloques
                                 where c.Descripcion == Obj.DescTipoReserva
                                 select c;

                if (querybusca.ToList().Count == 0)
                {
                    Model.CatTipoReserva.Add(Obj);
                    Model.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Beispiel #2
0
        public bool ActualizaTipoReserva(CatTipoReserva Obj)
        {
            try
            {
                BDVideosUSAVEntitiesModelSolicitudes Model = new BDVideosUSAVEntitiesModelSolicitudes();



                var querybusca = from c in Model.CatTipoReserva
                                 where c.DescTipoReserva == Obj.DescTipoReserva && c.IdTipoReserva != Obj.IdTipoReserva
                                 select c;
                if (querybusca.ToList().Count == 0)
                {
                    var objeto = Model.CatTipoReserva.FirstOrDefault(c => c.IdTipoReserva == Obj.IdTipoReserva);
                    objeto.IdTipoReserva   = Obj.IdTipoReserva;
                    objeto.DescTipoReserva = Obj.DescTipoReserva;
                    Model.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public Object PostGuardarReservas(object data)
 {
     try
     {
         CatTipoReserva Jloc    = JsonConvert.DeserializeObject <CatTipoReserva>(data.ToString());
         var            Reserva = new DataTipoReserva();
         if (Jloc.IdTipoReserva == 0)
         {
             return(Reserva.GuardarTipoReserva(Jloc));
         }
         else
         {
             return(Reserva.ActualizaTipoReserva(Jloc));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }