public void Delete(string schemaName, string tableName, string primaryKey)
        {
            try
            {
                var repository = new FormRepository(schemaName, tableName, this.MetaUser.Tenant, this.MetaUser.LoginId, this.MetaUser.UserId);
                repository.Delete(primaryKey);
            }
            catch (UnauthorizedException)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
            catch (DataAccessException ex)
            {
                throw new HttpResponseException(new HttpResponseMessage
                {
                    Content    = new StringContent(ex.Message),
                    StatusCode = HttpStatusCode.InternalServerError
                });
            }
#if !DEBUG
            catch
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
#endif
        }
Exemple #2
0
        public async Task <IHttpActionResult> Delete(Guid id)
        {
            var item = await repository.Get(id);

            if (!authorizationService.IsAuthorized(item.Id, user.Email, AuthorizationService.AuthorizationType.IsDelete, AuthorizationService.EndpointType.Form))
            {
                return(Content(HttpStatusCode.Forbidden, "You are not authorized to perform this action."));
            }
            else
            {
                repository.Delete(id);
                return(Content(HttpStatusCode.OK, ""));
            }
        }