Пример #1
0
        public static bool Insertar(Servicios servicio)
        {
            bool retorno = false;

            using (var db = new LavanderiaDb())
            {
                try
                {
                    if (Buscar(servicio.ServicioId) == null)
                    {
                        db.Servicio.Add(servicio);
                    }
                    else
                    {
                        db.Entry(servicio).State = System.Data.Entity.EntityState.Modified;
                    }
                    db.SaveChanges();
                    retorno = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                    //throw;
                }
                return(retorno);
            }
        }
Пример #2
0
        public static bool Insertar(Usuarios usuario)
        {
            bool retorno = false;

            using (var db = new LavanderiaDb())
            {
                try
                {
                    if (Buscar(usuario.UsuarioId) == null)
                    {
                        db.Usuario.Add(usuario);
                    }
                    else
                    {
                        db.Entry(usuario).State = System.Data.Entity.EntityState.Modified;
                    }
                    db.SaveChanges();
                    retorno = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(retorno);
            }
        }
Пример #3
0
        public static bool Eliminar(Servicios servicio)
        {
            bool retorno = false;

            using (var db = new LavanderiaDb())
            {
                try
                {
                    db.Entry(servicio).State = EntityState.Deleted;
                    db.SaveChanges();
                    retorno = true;
                }
                catch (Exception)
                {
                    throw;
                }
                return(retorno);
            }
        }