private static Credential generateCredantial( ModelContext context, bool state ) { try { Credential credential = new Credential() { CanCreate = state, CanRead = state, CanUpdate = state, CanDelete = state }; context.CredentialSet.AddOrUpdate( credential ); Log.Debug( $"generateCredantial: {credential.toString()}\nDONE" ); return credential; } catch ( DbEntityValidationException e ) { Log.Error( "generateCredantial", e ); return null; } catch ( Exception e ) { Log.Error( "generateCredantial", e ); return null; } }
// POST: odata/Credentials public IHttpActionResult Post(Credential credential) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CredentialSet.Add(credential); db.SaveChanges(); return Created(credential); }