Example #1
0
        public IHttpActionResult PutMechanicProfile(int id, MechanicProfile mechanicProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public IHttpActionResult GetMechanicProfile(int id)
        {
            MechanicProfile mechanicProfile = db.MechanicProfiles.Find(id);

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

            return(Ok(mechanicProfile));
        }
Example #3
0
        public IHttpActionResult PostMechanicProfile(MechanicProfile mechanicProfile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MechanicProfiles.Add(mechanicProfile);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = mechanicProfile.Id }, mechanicProfile));
        }
Example #4
0
        public IHttpActionResult DeleteMechanicProfile(int id)
        {
            MechanicProfile mechanicProfile = db.MechanicProfiles.Find(id);

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

            db.MechanicProfiles.Remove(mechanicProfile);
            db.SaveChanges();

            return(Ok(mechanicProfile));
        }