public async Task <IActionResult> PutTiposDocumento(int id, TiposDocumento tiposDocumento)
        {
            if (id != tiposDocumento.ID)
            {
                return(BadRequest());
            }

            _context.Entry(tiposDocumento).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TiposDocumentoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutMediosDePago(int id, MediosDePago mediosDePago)
        {
            if (id != mediosDePago.ID)
            {
                return(BadRequest());
            }

            _context.Entry(mediosDePago).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MediosDePagoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
        public IHttpActionResult PutEstiloCerveja(int id, EstiloCerveja estiloCerveja)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != estiloCerveja.IDEstilo)
            {
                return(BadRequest());
            }

            db.Entry(estiloCerveja).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EstiloCervejaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
        public async Task <IActionResult> PutSucursales(int id, Sucursales sucursales)
        {
            if (id != sucursales.ID)
            {
                return(BadRequest());
            }

            _context.Entry(sucursales).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SucursalesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #5
0
        public bool Salvar()
        {
            var ret   = 0;
            var model = ConsultarPeloId(this.PessoaId);

            using (var db = new ContextoDB())
            {
                if (this.Estado != null)
                {
                    this.EstadoId = this.Estado.Id;
                    this.Estado   = null;
                }

                if (this.Pessoa != null)
                {
                    this.PessoaId = this.Pessoa.Id;
                    this.Pessoa   = null;
                }

                if (model == null)
                {
                    db.EnderecoMap.Add(this);
                }
                else
                {
                    db.EnderecoMap.Attach(this);
                    db.Entry(this).State = EntityState.Modified;
                }

                db.SaveChanges();
                ret = this.Id;
            }
            return(!(ret == 0));
        }
Example #6
0
        public async Task <IActionResult> PutAperturaDeGavetas(int id, AperturaDeGavetas aperturaDeGavetas)
        {
            if (id != aperturaDeGavetas.ID)
            {
                return(BadRequest());
            }

            _context.Entry(aperturaDeGavetas).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AperturaDeGavetasExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public virtual void Actualizar(T obj)
 {
     using (var db = new ContextoDB())
     {
         db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Example #8
0
 public ActionResult Edit([Bind(Include = "Id,Nombre")] Carrera carrera)
 {
     if (ModelState.IsValid)
     {
         db.Entry(carrera).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(carrera));
 }
Example #9
0
 public void Actualizar(EMPLEADO P, USUARIO P2)
 {
     try
     {
         ContextoDB ct       = new ContextoDB();
         USUARIO    USUARIO  = ct.USUARIO.Where(x => x.CUsuario == P2.CUsuario).SingleOrDefault();
         EMPLEADO   EMPLEADO = ct.EMPLEADO.Where(x => x.CEmpleado == P.CEmpleado).SingleOrDefault();
         if (EMPLEADO != null && USUARIO != null)
         {
             ct.Entry(EMPLEADO).CurrentValues.SetValues(P);
             ct.Entry(USUARIO).CurrentValues.SetValues(P2);
             ct.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #10
0
 public ActionResult Edit([Bind(Include = "PessoaID,Nome,CPF")] Pessoa pessoa)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pessoa).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pessoa));
 }
Example #11
0
 public void Actualizar(CLIENTE P, USUARIO P2)
 {
     try
     {
         ContextoDB ct      = new ContextoDB();
         USUARIO    USUARIO = ct.USUARIO.Where(x => x.CUsuario == P2.CUsuario).SingleOrDefault();
         CLIENTE    CLIENTE = ct.CLIENTE.Where(x => x.CCliente == P.CCliente).SingleOrDefault();
         if (CLIENTE != null && USUARIO != null)
         {
             ct.Entry(CLIENTE).CurrentValues.SetValues(P);
             ct.Entry(USUARIO).CurrentValues.SetValues(P2);
             ct.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #12
0
 public ActionResult Edit([Bind(Include = "Id,Nombre,Apellido,UniversidadID,CarreraId,Email,Telefono,Celular")] Profesor profesor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(profesor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CarreraId     = new SelectList(db.Carreras, "Id", "Nombre", profesor.CarreraId);
     ViewBag.UniversidadID = new SelectList(db.Universidades, "Id", "Nombre", profesor.UniversidadID);
     return(View(profesor));
 }
Example #13
0
        public async Task <IActionResult> PutOrden(int id, Orden orden)
        {
            if (id != orden.ID)
            {
                return(BadRequest());
            }


            _context.Entry(orden).State = EntityState.Modified;
            foreach (var productoOrden in orden.ProductosPorOrden)
            {
                if (productoOrden.ID == 0)
                {
                    productoOrden.Productos = null;
                    await _context.ProductosPorOrden.AddAsync(productoOrden);
                }
                else
                {
                    _context.Entry(productoOrden).State = EntityState.Modified;
                }
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrdenExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #14
0
 public static bool excluirPeloId(int id)
 {
     using (var db = new ContextoDB())
     {
         var ponto = new Ponto {
             Id = id
         };
         db.Pontos.Attach(ponto);
         db.Entry(ponto).State = EntityState.Deleted;
         db.SaveChanges();
         return(true);
     }
 }
 public virtual void Agregar(T obj)
 {
     using (var db = new ContextoDB())
     {
         try
         {
             db.Entry(obj).State = System.Data.Entity.EntityState.Added;
             db.SaveChanges();
         }catch (DbEntityValidationException e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }
Example #16
0
        public void Actualizar(EVENTO P)
        {
            try
            {
                ContextoDB ct     = new ContextoDB();
                EVENTO     EVENTO = ct.EVENTO.Where(x => x.CEvento == P.CEvento).SingleOrDefault();

                if (EVENTO != null)
                {
                    ct.Entry(EVENTO).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #17
0
        public void Actualizar(USUARIO P)
        {
            try
            {
                ContextoDB ct      = new ContextoDB();
                USUARIO    USUARIO = ct.USUARIO.Where(x => x.CUsuario == P.CUsuario).SingleOrDefault();

                if (USUARIO != null)
                {
                    ct.Entry(USUARIO).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #18
0
        public void Actualizar(VENTA P)
        {
            try
            {
                ContextoDB ct    = new ContextoDB();
                VENTA      VENTA = ct.VENTA.Where(x => x.CVenta == P.CVenta).SingleOrDefault();

                if (VENTA != null)
                {
                    ct.Entry(VENTA).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #19
0
        public void Actualizar(TIPOEMPLEADO P)
        {
            try
            {
                ContextoDB   ct           = new ContextoDB();
                TIPOEMPLEADO TIPOEMPLEADO = ct.TIPOEMPLEADO.Where(x => x.CTipoEmpleado == P.CTipoEmpleado).SingleOrDefault();

                if (TIPOEMPLEADO != null)
                {
                    ct.Entry(TIPOEMPLEADO).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public ActionResult Cadastro([Bind(Include = "Id,Nome,Dono")] TimeModel timeModel)
 {
     if (ModelState.IsValid)
     {
         timeModel.Dono = User.GetNickName();
         if (timeModel.Id > 0)
         {
             db.Entry(timeModel).State = EntityState.Modified;
         }
         else
         {
             db.Times.Add(timeModel);
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(timeModel));
 }
Example #21
0
        public bool Excluir(int id)
        {
            var         ret = false;
            Funcionario obj = ConsultarPeloId(id);

            if (obj != null)
            {
                new Telefone().Excluir(id);

                using (var db = new ContextoDB())
                {
                    db.PessoaMap.Attach(obj);
                    db.Entry(obj).State = EntityState.Deleted;
                    db.SaveChanges();
                    ret = true;
                }
            }
            return(ret);
        }
Example #22
0
        public static int salvar(Trabalho trabalho)
        {
            using (var db = new ContextoDB())
            {
                var trabalhoBd = recuperarPeloId(trabalho.Id);

                if (trabalhoBd == null)
                {
                    db.Trabalhos.Add(trabalho);
                }
                else
                {
                    db.Trabalhos.Attach(trabalho);
                    db.Entry(trabalho).State = EntityState.Modified;
                }

                return(db.SaveChanges());
            }
        }
Example #23
0
        public void Actualizar(DETALLE_VENTA P)
        {
            try
            {
                ContextoDB    ct            = new ContextoDB();
                DETALLE_VENTA DETALLE_VENTA = (from x in ct.DETALLE_VENTA
                                               where x.CASiento == P.CASiento && x.CVenta == P.CVenta
                                               select x).FirstOrDefault();

                if (DETALLE_VENTA != null)
                {
                    ct.Entry(DETALLE_VENTA).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #24
0
        public ActionResult Cadastro(FormaPagamento formaPagamento)
        {
            if (ModelState.IsValid)
            {
                if (formaPagamento.Id > 0)
                {
                    db.Entry(formaPagamento).State = EntityState.Modified;
                }
                else
                {
                    db.FormaPagamento.Add(formaPagamento);
                }

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(formaPagamento));
        }
Example #25
0
        public ActionResult Cadastro(TipoEspaco tipoEspaco)
        {
            if (ModelState.IsValid)
            {
                if (tipoEspaco.Id > 0)
                {
                    db.Entry(tipoEspaco).State = EntityState.Modified;
                }
                else
                {
                    db.TipoEspaco.Add(tipoEspaco);
                }

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(tipoEspaco));
        }
Example #26
0
        public ActionResult Cadastro(PJ PJ)
        {
            if (ModelState.IsValid)
            {
                if (PJ.Id > 0)
                {
                    _db.Entry(PJ).State = EntityState.Modified;
                }
                else
                {
                    _db.PJ.Add(PJ);
                }

                _db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(PJ));
        }
Example #27
0
        public void Actualizar(ASIENTO_EVENTO P)
        {
            try
            {
                ContextoDB     ct             = new ContextoDB();
                ASIENTO_EVENTO ASIENTO_EVENTO = (from x in ct.ASIENTO_EVENTO
                                                 where x.CASiento == P.CASiento && x.CEvento == P.CEvento
                                                 select x).FirstOrDefault();

                if (ASIENTO_EVENTO != null)
                {
                    ct.Entry(ASIENTO_EVENTO).CurrentValues.SetValues(P);
                    ct.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public ActionResult Cadastro(Agendamento agendamento, int tipoCliente)
        {
            if (ModelState.IsValid)
            {
                if (agendamento.Id > 0)
                {
                    db.Entry(agendamento).State = EntityState.Modified;
                }
                else
                {
                    db.Agendamento.Add(agendamento);
                }

                db.SaveChanges();

                return(RedirectToAction("Index", new { id = tipoCliente == 1 ? agendamento.PFId : agendamento.PJId, tipoCliente = tipoCliente }));
            }

            ViewBag.ClientId    = tipoCliente == 1 ? agendamento.PFId : agendamento.PJId;
            ViewBag.TipoCliente = tipoCliente;

            return(View(agendamento));
        }
        public ActionResult Cadastro(PF pf)
        {
            if (ModelState.IsValid)
            {
                if (pf.Id > 0)
                {
                    var pfOnDb = _db.PF.Find(pf.Id);

                    TryUpdateModel(pfOnDb);

                    _db.Entry(pfOnDb).State = EntityState.Modified;
                }
                else
                {
                    _db.PF.Add(pf);
                }

                _db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(pf));
        }
Example #30
0
 //Modificar dados de Usuários cadastrados
 public void EditarUsuario(Usuario usuario)
 {
     db.Entry(usuario).State = EntityState.Modified;
     db.SaveChanges();
 }