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());
        }
示例#2
0
        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 })));
        }
示例#4
0
        public IHttpActionResult GetIncidenter(int id)
        {
            Incidenter incidenter = db.Incidenters.Find(id);

            if (incidenter == null)
            {
                return(NotFound());
            }

            return(Ok(incidenter));
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }