本文整理汇总了C#中System.Web.OData.Delta.Patch方法的典型用法代码示例。如果您正苦于以下问题:C# Delta.Patch方法的具体用法?C# Delta.Patch怎么用?C# Delta.Patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.OData.Delta
的用法示例。
在下文中一共展示了Delta.Patch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PatchToCompany
public IHttpActionResult PatchToCompany(int key, Delta<Company> company)
{
var navigateCompany = Employees.First(e => e.ID == key).Company;
company.Patch(Employees.First(e => e.ID == key).Company);
if (navigateCompany.Name == "Umbrella")
{
company.Patch(UmbrellaController.Umbrella);
}
else
{
return BadRequest();
}
return StatusCode(HttpStatusCode.NoContent);
}
示例2: Patch
public IHttpActionResult Patch([FromODataUri] int key, Delta<Category> patch)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
Category category = db.Categories.Find(key);
if (category == null)
{
return NotFound();
}
patch.Patch(category);
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!CategoryExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(category);
}
示例3: Patch
public IHttpActionResult Patch([FromODataUri] int key, Delta<Product> patch)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
Product product = db.Products.Find(key);
if (product == null)
{
return NotFound();
}
patch.Patch(product);
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!ProductExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(product);
}
示例4: Patch
public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<ETOPlaybook> product)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var entity = await _context.ETOPlaybooks.FindAsync(key);
if (entity == null)
{
return NotFound();
}
product.Patch(entity);
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
//if (!ProductExists(key))
//{
// return NotFound();
//}
//else
//{
throw;
//}
}
return Updated(entity);
}
示例5: Patch
public IHttpActionResult Patch(int key, Delta<Employee> employee)
{
Employee originalEmployee = Employees.Single(e => e.Id == key);
employee.Patch(originalEmployee);
return Ok(employee);
}
示例6: Patch
public async Task<IHttpActionResult> Patch([FromODataUri] string customerId, Delta<Customer> customer)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
var entity = await _Repository.GetEntityAsync(new FindCustomerByIdSpecificationStrategy(customerId));
if (entity == null)
return NotFound();
try
{
customer.Patch(entity);
_Repository.Modify(entity);
await _Repository.SaveAsync();
return Updated(entity);
}
catch (DbUpdateConcurrencyException)
{
if (!CustomerExists(customerId))
return NotFound();
else
throw;
}
}
示例7: Patch
public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Product> product)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var entity = await db.Products.FindAsync(key);
if (entity == null)
{
return NotFound();
}
product.Patch(entity);
try
{
await db.SaveChangesAsync();
}
catch (Exception ex)
{
if (!ProductExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(entity);
}
示例8: Patch
public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Customer> Customer)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var entity = await db.Customers.FindAsync(key);
if (entity == null)
{
return NotFound();
}
Customer.Patch(entity);
try
{
await db.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CustomerExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(entity);
}
示例9: Patch
public IHttpActionResult Patch([FromODataUri] int key, Delta<Order> patch)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
Order order = db.Orders.Find(key);
if (order == null)
{
return NotFound();
}
patch.Patch(order);
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!OrderExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(order);
}
示例10: PatchMe
public IHttpActionResult PatchMe(Delta<Person> patch)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
patch.Patch(TripPinSvcDataSource.Instance.Me);
return Updated(TripPinSvcDataSource.Instance.Me);
}
示例11: Patch
public IHttpActionResult Patch(int key, Delta<File> patch)
{
File original = _files.FirstOrDefault(c => c.FileId == key);
if (original == null)
{
return NotFound();
}
patch.Patch(original);
return Updated(original);
}
示例12: Patch
public IHttpActionResult Patch([FromODataUri] int key, Delta<ContactType> delta)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var contactType = _db.ContactType.Single(t => t.ContactTypeID == key);
delta.Patch(contactType);
_db.SaveChanges();
return Updated(contactType);
}
示例13: Patch
public IHttpActionResult Patch(int key, Delta<Account> patch)
{
IEnumerable<Account> appliedAccounts = Accounts.Where(a => a.Id == key);
if (appliedAccounts.Count() == 0)
{
return BadRequest(string.Format("The entry with Id {0} doesn't exist", key));
}
Account account = appliedAccounts.Single();
patch.Patch(account);
return Ok(account);
}
示例14: PatchPerson
public IHttpActionResult PatchPerson([FromODataUri] string firstName, [FromODataUri] string lastName, Delta<Person> delta)
{
var person = _repo.Get(firstName, lastName);
if (person == null)
{
return NotFound();
}
delta.Patch(person);
person.FirstName = firstName;
person.LastName = lastName;
_repo.UpdateOrAdd(person);
return Updated(person);
}
示例15: Patch
public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<ScheduledTask> entityDelta)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
var entity = await Context.ScheduledTasks.FindAsync(key);
if (entity == null)
{
return NotFound();
}
entityDelta.Patch(entity);
try
{
await Context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
return NotFound();
}
return Updated(entity);
}