public IHttpActionResult aPuttparaconfig(string id, tparaconfig tparaconfig)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tparaconfig.paratype)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult AddOrEdit(Employee emp)
 {
     using (DBModel1 db = new DBModel1())
     {
         if (emp.EmployeeID == 0)
         {
             db.Employees.Add(emp);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(emp).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Esempio n. 3
0
 public ActionResult AddorEdit(Trip trp)
 {
     using (DBModel1 db = new DBModel1())
     {
         if (trp.Id == 0)
         {
             db.Trips.Add(trp);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(trp).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }