示例#1
0
 /// <summary>
 /// Save changes to resource.
 /// </summary>
 /// <param name="id">Unique identifier for the resource.</param>
 /// <param name="resource">Updated resource.</param>
 /// <exception cref="System.Exception">Returns 304 NotModified if an exception occurs
 /// while saving the resource.</exception>
 public void Update(string id, Resource resource)
 {
     var previous = GetResource(id);
     if (previous != null) Delete(id);
     try
     {
         _ctx.Save<Resource>(resource);
     }
     catch (Exception ex)
     {
         if (previous != null) _ctx.Save<Resource>(previous);
         if (WebOperationContext.Current != null)
         {
             WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotModified;
         }
         Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(ex);
     }
 }
示例#2
0
 public void Act()
 {
     var newResource = new Resource(Context.Identity)
     {
         Title = "Test"
     };
     Context.Save<Resource>(newResource);
     Result = true;
 }