// 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);
        }
        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);
        }
 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);
 }
        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);
        }
        public IHttpActionResult Patch(int key, Delta<Employee> employee)
        {
            Employee originalEmployee = Employees.Single(e => e.Id == key);
            employee.Patch(originalEmployee);

            return Ok(employee);
        }
        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;
            }
        }
        // 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);
        }
        // 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);
        }
        // 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);
        }
Exemple #10
0
        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);
        }
        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);
        }
		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 );
		}
		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);
		}
        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);
        }
		public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<TranslatedCompany> delta, [ValueProvider(typeof(CultureValueProviderFactory))] string culture = "en-US")
		{
			var company = new Company(delta.GetEntity(), culture);
			company.Map = UpdateMapImage(company.Map);
			var tochange = _companiesManager.Patch(key, company);

			try
			{
				await _companiesManager.SaveChanges();
			}
			catch (DbUpdateConcurrencyException)
			{
				if (!_companiesManager.Exists(tochange.Id))
				{
					return NotFound();
				}
				else
				{
					throw;
				}
			}

			return Updated(tochange);

		}
Exemple #16
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Person> patch)
        {
            Validate(patch.GetEntity());

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

            Person person = db.People.Find(key);
            if (person == null)
            {
                return NotFound();
            }

            patch.Patch(person);

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

            return Updated(person);
        }
        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);
        }
        // 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);
        }
 public IHttpActionResult Patch([FromODataUri] long key, Delta<Product> patch)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
     return Updated(_repository.Patch(key, patch, Request));
 }
        public IHttpActionResult PatchMe(Delta<Person> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            patch.Patch(TripPinSvcDataSource.Instance.Me);
            return Updated(TripPinSvcDataSource.Instance.Me);
        }
        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);
        }
        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);
        }
 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);
 }
        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);
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta<PatchCustomer> patch)
        {
            PatchCustomer c = new PatchCustomer() { Id = key, ExtraProperty = "Some value" };
            patch.Patch(c);
            Validate(c);
            if (ModelState.IsValid)
            {
                return Ok(c);

            }
            else
            {
                return BadRequest(ModelState);
            }
        }
Exemple #26
0
        public IHttpActionResult Patch([FromODataUri]int key, Delta<Supplier> changedSupplier)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var originalSupplier = _suppliers.SingleOrDefault(p => p.Id == key);
            if (originalSupplier == null)
            {
                return NotFound();
            }

            changedSupplier.CopyChangedValues(originalSupplier);
            return Ok();
        }
        // PATCH odata/Airlines('key')
        public IHttpActionResult Patch([FromODataUri] string key, Delta<Airline> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var airline = TripPinSvcDataSource.Instance.Airlines.SingleOrDefault(item => item.AirlineCode == key);
            if (airline == null)
            {
                return NotFound();
            }

            patch.Patch(airline);
            return Updated(airline);
        }
        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);
        }
Exemple #29
0
        public IHttpActionResult Patch([FromODataUri]int key, Delta<Product> changedProduct)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var originalProduct = _products.SingleOrDefault(p => p.Id == key);
            if (originalProduct == null)
            {
                return NotFound();
            }

            changedProduct.CopyChangedValues(originalProduct);
            return StatusCode(HttpStatusCode.OK);
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Product> delta)
        {
            Validate(delta.GetEntity());

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

            // TODO: Get the entity here.

            // delta.Patch(product);

            // TODO: Save the patched entity.

            // return Updated(product);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
Exemple #31
0
        public void CanCreateDeltaOfDerivedTypes()
        {
            var delta = new Delta <Base>(typeof(Derived));

            Assert.IsType(typeof(Derived), delta.GetEntity());
        }
Exemple #32
0
        public void Can_Declare_A_Delta_Of_An_AbstractClass()
        {
            Delta <AbstractBase> abstractDelta = null;

            Assert.Null(abstractDelta);
        }