public IHttpActionResult PutOrderDetail(int id, OrderDetail orderDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderDetail.orderId) { return(BadRequest()); } db.Entry(orderDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "Id,Name,LastName,BirthDate,DisplayBirthDate,Email,City")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create(peopleinfo peopleinfo) { if (ModelState.IsValid) { db.peopleinfo.Add(peopleinfo); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(peopleinfo)); }
public JsonResult SaveDataInDatabase(PersonViewModel model) { var result = false; try { if (model.Id > 0) { Person Pers = db.People.SingleOrDefault(x => x.IsDeleted == false && x.Id == model.Id); Pers.firstname = model.firstname; Pers.lastname = model.lastname; Pers.birthday = model.birthday; Pers.email = model.email; Pers.phone = model.phone; Pers.company = model.company; Pers.zipcode = model.zipcode; db.SaveChanges(); result = true; } else { Person Pers = new Person(); Pers.Id = model.Id; Pers.firstname = model.firstname; Pers.lastname = model.lastname; Pers.birthday = model.birthday; Pers.email = model.email; Pers.phone = model.phone; Pers.company = model.company; Pers.zipcode = model.zipcode; Pers.IsDeleted = false; db.People.Add(Pers); db.SaveChanges(); result = true; } } catch (Exception ex) { throw ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }