public IHttpActionResult PutMuncipalCAN(decimal id, MuncipalCAN muncipalCAN)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != muncipalCAN.PhoneNumber)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Create(studentnew std1)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.studentnews.Add(std1);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(std1));
     }
     catch
     {
         return(View());
     }
 }
 public void Atualiza(tb_produtos2 produto)
 {
     using (var db = new masterEntities2())
     {
         db.Entry(produto).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public void AdicionaDb(tb_produtos2 product)
 {
     using (var db = new masterEntities2())
     {
         db.tb_produtos2.Add(new tb_produtos2()
         {
             Nome = product.Nome, Preco = product.Preco, Quantidade = product.Quantidade, id = product.id
         });
         db.SaveChanges();
     }
 }
Beispiel #5
0
        public ActionResult insert(tblemployee emp)
        {
            masterEntities2 entity = new masterEntities2();
            tblemployee     obj    = new tblemployee();

            obj.firstname = emp.firstname;
            obj.lastname  = emp.lastname;
            obj.address   = emp.address;
            obj.phone     = emp.phone;
            entity.tblemployees.Add(obj);
            entity.SaveChanges();
            return(RedirectToAction("show"));
        }