Beispiel #1
0
        public IHttpActionResult PostGLAS(GLAS gLAS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.GLAS.Add(gLAS);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (GLASExists(gLAS.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = gLAS.ID }, gLAS));
        }
Beispiel #2
0
        public IHttpActionResult PutGLAS(int id, GLAS gLAS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != gLAS.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> Edit(int id, GLAS Emp)
        {
            HttpResponseMessage responseMessage = await client.PutAsJsonAsync(url + "/" + id, Emp);

            if (responseMessage.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error"));
        }
        public async Task <ActionResult> Create(GLAS tipGLAa)
        {
            HttpResponseMessage responseMessage = await client.PostAsJsonAsync(url, tipGLAa);

            if (responseMessage.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error"));
        }
        public async Task <ActionResult> Delete(int id, GLAS tipGLAa)
        {
            HttpResponseMessage responseMessage = await client.DeleteAsync(url + "/" + id);

            if (responseMessage.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Error"));
        }
Beispiel #6
0
        public IHttpActionResult GetGLAS(int id)
        {
            GLAS gLAS = db.GLAS.Find(id);

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

            return(Ok(gLAS));
        }
Beispiel #7
0
        public IHttpActionResult DeleteGLAS(int id)
        {
            GLAS gLAS = db.GLAS.Find(id);

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

            db.GLAS.Remove(gLAS);
            db.SaveChanges();

            return(Ok(gLAS));
        }