// POST: odata/Applications public IHttpActionResult Post(tblApplication tblApplication) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } tblApplication.ID = Guid.NewGuid(); tblApplication.CreatedBy = User.Identity.Name; tblApplication.ModifiedBy = User.Identity.Name; tblApplication.CreatedDate = DateTime.Now; tblApplication.ModifiedDate = tblApplication.CreatedDate; db.tblApplication.Add(tblApplication); try { db.SaveChanges(); } catch (DbUpdateException) { if (tblApplicationExists(tblApplication.ID)) { return(Conflict()); } else { throw; } } return(Created(tblApplication)); }
// POST: odata/Applications public IHttpActionResult Post(tblApplication tblApplication) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tblApplication.Add(tblApplication); try { db.SaveChanges(); } catch (DbUpdateException) { if (tblApplicationExists(tblApplication.ID)) { return(Conflict()); } else { throw; } } return(Created(tblApplication)); }
public ActionResult DeleteConfirmed(int id) { tblApplication tblApplication = db.tblApplications.Find(id); db.tblApplications.Remove(tblApplication); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Application_ID,Application_Name,Type,Description")] tblApplication tblApplication) { if (ModelState.IsValid) { db.Entry(tblApplication).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblApplication)); }
public ActionResult Create([Bind(Include = "Application_ID,Application_Name,Type,Description")] tblApplication tblApplication) { if (ModelState.IsValid) { db.tblApplications.Add(tblApplication); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblApplication)); }
// DELETE: odata/Applications(5) public IHttpActionResult Delete([FromODataUri] Guid key) { tblApplication tblApplication = db.tblApplication.Find(key); if (tblApplication == null) { return(NotFound()); } db.tblApplication.Remove(tblApplication); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// GET: Applications/Delete/6 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblApplication tblApplication = db.tblApplications.Find(id); if (tblApplication == null) { return(HttpNotFound()); } return(View(tblApplication)); }
// PUT: odata/Applications(5) public IHttpActionResult Put([FromODataUri] Guid key, Delta <tblApplication> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } tblApplication tblApplication = db.tblApplication.Find(key); if (tblApplication == null) { return(NotFound()); } patch.GetEntity().ModifiedDate = DateTime.Now; patch.GetEntity().ModifiedBy = User.Identity.Name; patch.Put(tblApplication); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblApplicationExists(key)) { return(NotFound()); } else { throw; } } return(Updated(tblApplication)); }