コード例 #1
0
ファイル: CustomerHandler.cs プロジェクト: lanicon/csharp-res
        // Applies the delete to the database if it existed,
        // or else throws a ResError.NotFound ResException.
        public void ApplyDelete(IResourceContext resource, DeleteEventArgs ev)
        {
            var id       = new ObjectId(resource.PathParam("id"));
            var customer = customers.FindById(id);

            if (customer == null)
            {
                throw new ResException(ResError.NotFound);
            }
            customers.Delete(Query.EQ("_id", id));
            ev.SetRevert(customer);
        }