当前位置: 首页>>代码示例>>C#>>正文


C# Delta.Patch方法代码示例

本文整理汇总了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);
 }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:14,代码来源:EmployeesController.cs

示例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);
        }
开发者ID:respag,项目名称:NorthwindAPI,代码行数:33,代码来源:CategoriesController.cs

示例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);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:33,代码来源:ProductsV2Controller.cs

示例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);
 }
开发者ID:manuelbautista,项目名称:Milestone-MVC-Project,代码行数:29,代码来源:ETOPlaybookDTOController.cs

示例5: Patch

        public IHttpActionResult Patch(int key, Delta<Employee> employee)
        {
            Employee originalEmployee = Employees.Single(e => e.Id == key);
            employee.Patch(originalEmployee);

            return Ok(employee);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:7,代码来源:OpenTypeControllers.cs

示例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;
            }
        }
开发者ID:NRepository,项目名称:Northwind-Sample,代码行数:26,代码来源:CustomersController.cs

示例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);
        }
开发者ID:zidanfei,项目名称:OData,代码行数:34,代码来源:ProductsController.cs

示例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);
		}
开发者ID:joshcomley,项目名称:WebApi,代码行数:29,代码来源:CustomersController.cs

示例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);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:33,代码来源:OrdersV2Controller.cs

示例10: PatchMe

        public IHttpActionResult PatchMe(Delta<Person> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            patch.Patch(TripPinSvcDataSource.Instance.Me);
            return Updated(TripPinSvcDataSource.Instance.Me);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:10,代码来源:SingletonController.cs

示例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);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:11,代码来源:DateTimeController.cs

示例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);
        }
开发者ID:diouf,项目名称:WebAPIODataV4,代码行数:12,代码来源:ContactTypeController.cs

示例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);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:14,代码来源:AccountsController.cs

示例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);
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:16,代码来源:PeopleController.cs

示例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);
 }
开发者ID:ruisebastiao,项目名称:zVirtualScenes,代码行数:22,代码来源:ScheduledTasksController.cs


注:本文中的System.Web.OData.Delta.Patch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。