Пример #1
0
        public IHttpActionResult PutMechanicNotification(int id, MechanicNotification mechanicNotification)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mechanicNotification.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #2
0
        public IHttpActionResult GetMechanicNotification(int id)
        {
            MechanicNotification mechanicNotification = db.MechanicNotifications.Find(id);

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

            return(Ok(mechanicNotification));
        }
Пример #3
0
        public IHttpActionResult PostMechanicNotification(MechanicNotification mechanicNotification)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MechanicNotifications.Add(mechanicNotification);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mechanicNotification.Id }, mechanicNotification));
        }
Пример #4
0
        public IHttpActionResult DeleteMechanicNotification(int id)
        {
            MechanicNotification mechanicNotification = db.MechanicNotifications.Find(id);

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

            db.MechanicNotifications.Remove(mechanicNotification);
            db.SaveChanges();

            return(Ok(mechanicNotification));
        }