Beispiel #1
0
        public async Task <IActionResult> PutRequisition([FromRoute] int id, [FromBody] Requisition requisition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != requisition.RequisitionId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutTypeProduct([FromRoute] int id, [FromBody] TypeProduct typeProduct)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != typeProduct.TypeProductId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutPurchaseDetail([FromRoute] int id, [FromBody] PurchaseDetail purchaseDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != purchaseDetail.PurchaseDetailId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "ID,idPaciente,nombre,edad,peso,estatura")] Paciente paciente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(paciente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(paciente));
 }
Beispiel #5
0
 public ActionResult Edit([Bind(Include = "ID,Nome")] Professor professor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(professor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(professor));
 }
Beispiel #6
0
        public void Deletar(Cdespesa obj)
        {
            using (var ctx = new SistemaContext())
            {
                ctx.Entry(obj).State = System.Data.Entity.EntityState.Deleted;
                ctx.SaveChanges();

                //Ccusto obj = ctx.Ccusto.Find(id); //LOCALIZA O ID PARA A DELECAO
                //ctx.Ccusto.Remove(obj); // DELETA O REGISTRO
                //ctx.SaveChanges();
            }
        }
Beispiel #7
0
        public void Modificar(Cdespesa obj)
        {
            using (var ctx = new SistemaContext()) //PASSA OS DADOS DA OBJETO ANTIGO PARA O OBJETO NOVO E ATUALIZA NO BANCO
            {
                ctx.Cdespesa.Attach(obj);
                ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();

                //Ccusto objOld = ctx.Ccusto.SingleOrDefault(x => x.Id_cc == objNew.Id_cc);
                //objOld.Cd_custo = objNew.Cd_custo;
                //objOld.De_custo = objNew.De_custo;
                //objOld.Fg_ativo = objNew.Fg_ativo;
                //ctx.SaveChanges(); //SALVA AS ALTERACOES
            }
        }
Beispiel #8
0
        public ActionResult Edit([Bind(Include = "ID,Nome,DataNascimento,ProfessorID")] Aluno aluno)
        {
            if (ModelState.IsValid)
            {
                if (aluno.DataNascimento.Date >= DateTime.Now.Date)
                {
                    ModelState.AddModelError("", "A data de nascimento deve ser anterior à data atual!");
                    ViewBag.ProfessorID = new SelectList(db.Professores, "ID", "Nome", aluno.ProfessorID);
                    return(View(aluno));
                }

                db.Entry(aluno).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ProfessorID = new SelectList(db.Professores, "ID", "Nome", aluno.ProfessorID);
            return(View(aluno));
        }
Beispiel #9
0
 public object Update(int IdEntidadeAutenticadora, object newObject)
 {
     try
     {
         EntidadeAutenticadora r = (from p in context.EntidadeAutenticadora where p.IdEntidadeAutenticadora == IdEntidadeAutenticadora select p).FirstOrDefault <EntidadeAutenticadora>();
         foreach (var att in ((EntidadeAutenticadora)newObject).GetType().GetProperties())
         {
             if (!att.Name.Equals("IdEntidadeAutenticadora"))
             {
                 r.GetType().GetProperty(att.Name).SetValue(r, att.GetValue(newObject));
             }
         }
         context.Entry(r).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         context.SaveChanges();
         return(r);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }