當前位置: 首頁>>代碼示例>>C#>>正文


C# OData.Delta類代碼示例

本文整理匯總了C#中System.Web.OData.Delta的典型用法代碼示例。如果您正苦於以下問題:C# Delta類的具體用法?C# Delta怎麽用?C# Delta使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Delta類屬於System.Web.OData命名空間,在下文中一共展示了Delta類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Put

        // PUT: odata/Notes(5)
        public async Task<IHttpActionResult> Put([FromODataUri] Guid key, Delta<Note> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Note note = await db.Notes.FindAsync(key);
            if (note == null)
            {
                return NotFound();
            }

            patch.Put(note);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NoteExists(key))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return Updated(note);
        }
開發者ID:NicoJuicy,項目名稱:blog-todomvc-angular-odata,代碼行數:36,代碼來源:NotesController.cs

示例2: 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

示例3: 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

示例4: 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

示例5: Patch

        public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Customer> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var customer = await _db.Customers.FindAsync(key);
            if (customer == null)
            {
                return NotFound();
            }

            patch.Patch(customer);

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(key))
                {
                    return NotFound();
                }
                throw;
            }

            return Updated(customer);
        }
開發者ID:chauey,項目名稱:Swashbuckle.OData,代碼行數:32,代碼來源:CustomersController.cs

示例6: Put

        // PUT: odata/IMEI(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<IMEIToCallsign> patch)
        {
            var imeiToCallsign = await _imeiService.GetFromId(key);
            if (imeiToCallsign == null)
            {
                return NotFound();
            }

            patch.Put(imeiToCallsign);

            Validate(imeiToCallsign);

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            await _imeiService.RegisterCallsign(imeiToCallsign.IMEI, imeiToCallsign.CallSign, imeiToCallsign.Type);

            var newIMEI = await _imeiService.GetFromIMEI(imeiToCallsign.IMEI);

            await _logService.LogIMEIRegistered(User.Identity.GetUserName(), newIMEI.IMEI, newIMEI.CallSign, newIMEI.Type);

            return Updated(newIMEI);
        }
開發者ID:trichards57,項目名稱:new-bike-tracker,代碼行數:26,代碼來源:IMEIController.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: Put

        // PUT: odata/Claims(5)
        public async Task<IHttpActionResult> Put([FromODataUri] Guid key, Delta<Claim> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var claim = await db.Claims.FindAsync(key);
            if (claim == null)
            {
                return NotFound();
            }

            patch.Put(claim);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClaimExists(key))
                {
                    return NotFound();
                }
                throw;
            }

            return Updated(claim);
        }
開發者ID:chivandikwa,項目名稱:Angular-Starter,代碼行數:33,代碼來源:ClaimsController.cs

示例9: Patch

		public async Task<IHttpActionResult> Patch( [FromODataUri] int key, Delta<Account> patch )
		{
			Validate( patch.GetEntity() );

			if ( !ModelState.IsValid )
			{
				return BadRequest( ModelState );
			}

			var user = await _db.Accounts.SingleOrDefaultAsync( u => u.Id == key );
			if ( user == null )
			{
				return NotFound();
			}

			patch.Patch( user );

			try
			{
				await _db.SaveChangesAsync();
			}
			catch ( DbUpdateConcurrencyException )
			{
				if ( !ApplicationUserExists( key ) )
				{
					return NotFound();
				}
				else
				{
					throw;
				}
			}

			return Updated( user );
		}
開發者ID:MusicCityCode,項目名稱:ConferenceServices,代碼行數:35,代碼來源:UsersController.cs

示例10: 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

示例11: 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

示例12: 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

示例13: Patch

        public IHttpActionResult Patch([FromODataUri] int key, Delta<OptionSetEntity> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            OptionSetEntity optionSetEntity = db.OptionSetEntities.Find(key);
            if (optionSetEntity == null)
            {
                return NotFound();
            }

            patch.Patch(optionSetEntity);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OptionSetEntityExists(key))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return Updated(optionSetEntity);
        }
開發者ID:DureSameen,項目名稱:ContactsCRMOdata,代碼行數:35,代碼來源:OptionSetEntitiesController.cs

示例14: Put

        // PUT: odata/Students(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<Student> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Student student = await db.Students.FindAsync(key);
            if (student == null)
            {
                return NotFound();
            }

            patch.Put(student);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(key))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return Updated(student);
        }
開發者ID:gyb333,項目名稱:Gyb.Platform,代碼行數:36,代碼來源:StudentsController.cs

示例15: Put

        // PUT: odata/PlatformsImporter(5)
        public async Task<IHttpActionResult> Put([FromODataUri] string key, Delta<Platform> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Platform platform = await db.Platforms.FindAsync(key);
            if (platform == null)
            {
                return NotFound();
            }

            patch.Put(platform);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlatformExists(key))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return Updated(platform);
        }
開發者ID:pandazzurro,項目名稱:uPlayAgain,代碼行數:36,代碼來源:PlatformsImporterController.cs


注:本文中的System.Web.OData.Delta類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。