Exemple #1
0
        public IHttpActionResult PostMunitionRoles(MunitionRole munitionRoles)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.MunitionRoles.Add(munitionRoles);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (MunitionRolesExists(munitionRoles.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApiPost", new { id = munitionRoles.id }, munitionRoles));
        }
Exemple #2
0
        public IHttpActionResult PutMunitionRoles(int id, MunitionRole munitionRoles)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public IHttpActionResult DeleteMunitionRoles(int id)
        {
            MunitionRole munitionRoles = db.MunitionRoles.Find(id);

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

            db.MunitionRoles.Remove(munitionRoles);
            db.SaveChanges();

            return(Ok(munitionRoles));
        }
Exemple #4
0
        public IHttpActionResult GetMunitionRoles(int id)
        {
            MunitionRole munitionRoles = db.MunitionRoles.Find(id);

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

            return(Ok(new DropDownDTO
            {
                id = munitionRoles.id.ToString(),
                description = munitionRoles.description
            }));
        }