Exemplo n.º 1
0
        // POST: odata/RoleRightsViews
        public async Task <IHttpActionResult> Post(RoleRightsView roleRightsView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.RoleRightsViews.Add(roleRightsView);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (RoleRightsViewExists(roleRightsView.RightsId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(roleRightsView));
        }
Exemplo n.º 2
0
        // DELETE: odata/RoleRightsViews(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] short key)
        {
            RoleRightsView roleRightsView = await db.RoleRightsViews.FindAsync(key);

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

            db.RoleRightsViews.Remove(roleRightsView);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 3
0
        // PUT: odata/RoleRightsViews(5)
        public async Task <IHttpActionResult> Put([FromODataUri] short key, Delta <RoleRightsView> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            RoleRightsView roleRightsView = await db.RoleRightsViews.FindAsync(key);

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

            patch.Put(roleRightsView);

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

            return(Updated(roleRightsView));
        }