Пример #1
0
 public ActionResult ReadedAlertAjax(AlertsIBO model)
 {
     if (model != null)
     {
         model.datetime = DateTime.Now;
         BaseClient client = new BaseClient(baseApiUrl, "AlertsIBO", "PostAlertIBO");
         bool       result = client.Post <AlertsIBO>(model);
     }
     return(Json(new { success = true }));
 }
        // GET api/AlertsIBO/5
        public AlertsIBO GetAlertIBO(string id)
        {
            AlertsIBO alertibo = db.AlertsIBOes.Find(id);

            if (alertibo == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(alertibo);
        }
        // POST api/AlertsIBO
        public HttpResponseMessage PostAlertIBO(AlertsIBO alertibo)
        {
            if (ModelState.IsValid)
            {
                db.AlertsIBOes.Add(alertibo);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, alertibo);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = alertibo.AlertId }));
                return(response);
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        // DELETE api/AlertsIBO/5
        public HttpResponseMessage DeleteAlertIBO(string id)
        {
            AlertsIBO alertibo = db.AlertsIBOes.Find(id);

            if (alertibo == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.AlertsIBOes.Remove(alertibo);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, alertibo));
        }
        // PUT api/AlertsIBO/5
        public HttpResponseMessage PutAlertIBO(string id, AlertsIBO alertibo)
        {
            if (ModelState.IsValid && id == alertibo.AlertId)
            {
                db.Entry(alertibo).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }