public ActionResult IncidentsDetailFault() { if (ModelState.IsValid) { var txtidtr = Request["txtIncidenter"]; var in_id = Int32.Parse(Request.QueryString["inID"]); if (Logic.LogicMethods.ValidateAlphaNumericLength(txtidtr)) { Incidenter incdtr = new Incidenter() { Name = txtidtr.ToString() }; db.Incidents.Where(i => i.Id == in_id).Include(d => d.Incidenters).FirstOrDefault().Incidenters.Add(incdtr); db.SaveChanges(); ModelState.Clear(); } return(RedirectToAction("IncidentsDetail", new RouteValueDictionary(new { inID = in_id }))); } return(View()); }
public IHttpActionResult PutIncidenter(int id, Incidenter incidenter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != incidenter.Id) { return(BadRequest()); } db.Entry(incidenter).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IncidenterExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult DeleteIncidenter(int faultID) { Incidenter incidenter = db.Incidenters.Find(faultID); var in_id = db.Incidents.Include(i => i.Incidenters).Where(i => i.Incidenters.Any(id => id.Id == faultID)).FirstOrDefault().Id; db.Incidenters.Remove(incidenter); db.SaveChanges(); return(RedirectToAction("IncidentsDetail", new RouteValueDictionary(new { inID = in_id }))); }
public IHttpActionResult GetIncidenter(int id) { Incidenter incidenter = db.Incidenters.Find(id); if (incidenter == null) { return(NotFound()); } return(Ok(incidenter)); }
public IHttpActionResult PostIncidenter(Incidenter incidenter) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Incidenters.Add(incidenter); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = incidenter.Id }, incidenter)); }
public IHttpActionResult DeleteIncidenter(int id) { Incidenter incidenter = db.Incidenters.Find(id); if (incidenter == null) { return(NotFound()); } db.Incidenters.Remove(incidenter); db.SaveChanges(); return(Ok(incidenter)); }