// POST: api/Utilities.svc/StateChangeLocks
        public async Task<IHttpActionResult> Post(StateChangeLock stateChangeLock)
        {
            var declaringType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
            var fn = String.Format("{0}:{1}",
                declaringType.Namespace,
                declaringType.Name);

            if (!ModelState.IsValid)
            {
                Debug.WriteLine("StateChangeLock to be created has invalid ModelState.");
                return BadRequest(ModelState);
            }
            try
            {
                Debug.WriteLine(fn);

                var identity = CurrentUserDataProvider.GetIdentity(TenantId);

                var permissionId = CreatePermissionId("CanCreate");
                if (!identity.Permissions.Contains(permissionId))
                {
                    return StatusCode(HttpStatusCode.Forbidden);
                }
                if (null == stateChangeLock)
                {
                    var errorMsg = "StateChangeLock to be created contains invalid data.";
                    Debug.WriteLine(errorMsg);
                    return BadRequest(errorMsg);
                }
                Debug.WriteLine("Saving new StateChangeLock for entity with id '{0}'...", 
                    stateChangeLock.EntityId);

                var stateChangeLockEntity = new StateChangeLock()
                {
                    CreatedBy = identity.Username,
                    Created = DateTimeOffset.Now,
                    Tid = identity.Tid,
                    EntityId = stateChangeLock.EntityId,
                };
                stateChangeLockEntity = db.StateChangeLocks.Add(stateChangeLockEntity);
                db.SaveChanges();
                Debug.WriteLine("Saved StateChangeLock for entity with id '{0}'", 
                    stateChangeLockEntity.EntityId);
                return ResponseMessage(ODataControllerHelper.ResponseCreated(this, stateChangeLockEntity));
            }
            catch (Exception e)
            {
                Debug.WriteLine(String.Format("{0}: {1}\r\n{2}", e.Source, e.Message, e.StackTrace));
                throw;
            }
        }
        // PUT: api/Utilities.svc/StateChangeLocks(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, StateChangeLock stateChangeLock)
        {
            var declaringType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
            var fn = String.Format("{0}:{1}",
                declaringType.Namespace,
                declaringType.Name);

            if (!ModelState.IsValid)
            {
                Debug.WriteLine("StateChangeLock to be updated with id '{0}' has invalid ModelState.", key);
                return BadRequest(ModelState);
            }

            if (key != stateChangeLock.Id)
            {
                return BadRequest();
            }

            Debug.WriteLine(fn);

            // TODO: Add replace logic here.

            // return Updated(stateChangeLock);
            return StatusCode(HttpStatusCode.NotImplemented);
        }