Esempio n. 1
0
        public async Task <IHttpActionResult> PutHalyty(int id, Halyty halyty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != halyty.HalytinId)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HalytyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> GetHalyty(int id)
        {
            Halyty halyty = await db.Halytys.FindAsync(id);

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

            return(Ok(halyty));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> PostHalyty(Halyty halyty)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Halytys.Add(halyty);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = halyty.HalytinId }, halyty));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> DeleteHalyty(int id)
        {
            Halyty halyty = await db.Halytys.FindAsync(id);

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

            db.Halytys.Remove(halyty);
            await db.SaveChangesAsync();

            return(Ok(halyty));
        }