示例#1
0
        public IHttpActionResult PutPodetail(string id, Podetail podetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != podetail.pono)
            {
                return(BadRequest());
            }

            db.Entry(podetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PodetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult PostPodetail(Podetail podetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Podetails.Add(podetail);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (PodetailExists(podetail.pono))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = podetail.pono }, podetail));
        }
示例#3
0
        public ActionResult Create(Podetail podetail)
        {
            try
            {
                using (client)
                {
                    Task <HttpResponseMessage> responseTask = client.PostAsJsonAsync(url, podetail);
                    responseTask.Wait();

                    //To store result of web api response.
                    HttpResponseMessage result = responseTask.Result;

                    //If success received
                    if (result.IsSuccessStatusCode)
                    {
                        Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>();
                        readTask.Wait();

                        podetail = readTask.Result;
                    }
                };

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#4
0
        public ActionResult Delete(string pono, string itcode, Podetail podetail)
        {
            try
            {
                using (client)
                {
                    Task <HttpResponseMessage> responseTask = client.DeleteAsync(url + "?pono=" + pono + "&itcode=" + itcode);
                    responseTask.Wait();

                    //To store result of web api response.
                    HttpResponseMessage result = responseTask.Result;

                    //If success received
                    if (result.IsSuccessStatusCode)
                    {
                        Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>();
                        readTask.Wait();

                        podetail = readTask.Result;
                    }
                };

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#5
0
        public IHttpActionResult GetPodetail(string id)
        {
            Podetail podetail = db.Podetails.Find(id);

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

            return(Ok(podetail));
        }
示例#6
0
        public IHttpActionResult DeletePodetail(string id)
        {
            Podetail podetail = db.Podetails.Find(id);

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

            db.Podetails.Remove(podetail);
            db.SaveChanges();

            return(Ok(podetail));
        }
示例#7
0
        // GET: Podetails/Details/5
        public ActionResult Details(string pono, string itcode)
        {
            Podetail podetail = new Podetail();

            using (client)
            {
                Task <HttpResponseMessage> responseTask = client.GetAsync(url + "?pono=" + pono + "&itcode=" + itcode);
                responseTask.Wait();

                //To store result of web api response.
                HttpResponseMessage result = responseTask.Result;

                //If success received
                if (result.IsSuccessStatusCode)
                {
                    Task <Podetail> readTask = result.Content.ReadAsAsync <Podetail>();
                    readTask.Wait();

                    podetail = readTask.Result;
                }
            };
            return(View(podetail));
        }