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

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

            ActiveHotelProduct activeHotelProduct = await db.ActiveHotelProduct.FindAsync(key);
            if (activeHotelProduct == null)
            {
                return NotFound();
            }

            patch.Put(activeHotelProduct);

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

            return Updated(activeHotelProduct);
        }
        // PUT: odata/OrganizationIdentityDirectory(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<OrganizationIdentityDirectory> patch)
        {
            Validate(patch.GetEntity());

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

            OrganizationIdentityDirectory organizationIdentityDirectory = await db.OrganizationIdentityDirectory.FindAsync(key);
            if (organizationIdentityDirectory == null)
            {
                return NotFound();
            }

            patch.Put(organizationIdentityDirectory);

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

            return Updated(organizationIdentityDirectory);
        }
        // PUT: odata/Customers(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<Customer> patch)
        {
            Validate(patch.GetEntity());

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

            Customer customer = db.Customers.Find(key);
            if (customer == null)
            {
                return NotFound();
            }

            patch.Put(customer);

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

            return Updated(customer);
        }
Exemple #4
0
        // PUT: odata/Parking(5)
        public async Task<IHttpActionResult> Put([FromODataUri] long key, Delta<Parking> patch)
        {
            Validate(patch.GetEntity());

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

            Parking parking = await db.Parkings.FindAsync(key);
            if (parking == null)
            {
                return NotFound();
            }

            patch.Put(parking);

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

            return Updated(parking);
        }
        // PUT: odata/UserInfoViewModels(5)
        public async Task<IHttpActionResult> Put([FromODataUri] string key, Delta<UserInfoViewModel> patch)
        {
            Validate(patch.GetEntity());

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

            UserInfoViewModel userInfoViewModel = await db.UserInfoViewModels.FindAsync(key);
            if (userInfoViewModel == null)
            {
                return NotFound();
            }

            patch.Put(userInfoViewModel);

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

            return Updated(userInfoViewModel);
        }
        // PUT: odata/Basic_Information1(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<Basic_Information> patch)
        {
            Validate(patch.GetEntity());

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

            Basic_Information basic_Information = await db.Basic_Information.FindAsync(key);
            if (basic_Information == null)
            {
                return NotFound();
            }

            patch.Put(basic_Information);

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

            return Updated(basic_Information);
        }
        // PUT: odata/Applications(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<Application> patch)
        {
            Validate(patch.GetEntity());

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

            Application application = db.Applications.Find(key);
            if (application == null)
            {
                return NotFound();
            }

            patch.Put(application);

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

            return Updated(application);
        }
        // PUT: odata/FoodDescriptions(5)
        public async Task<IHttpActionResult> Put([FromODataUri] string key, Delta<FoodDescription> patch)
        {
            Validate(patch.GetEntity());

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

            FoodDescription foodDescription = await db.FoodDescriptions.FindAsync(key);
            if (foodDescription == null)
            {
                return NotFound();
            }

            patch.Put(foodDescription);

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

            return Updated(foodDescription);
        }
        // PUT: odata/RelUserModules(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<RelUserModule> patch)
        {
            Validate(patch.GetEntity());

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

            RelUserModule relUserModule = await db.RelUserModule.FindAsync(key);
            if (relUserModule == null)
            {
                return NotFound();
            }

            patch.Put(relUserModule);

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

            return Updated(relUserModule);
        }
        // PUT: odata/Results(5)
        public IHttpActionResult Put([FromODataUri] Guid key, Delta<Result> patch)
        {
            Validate(patch.GetEntity());

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

            Result result = db.Results.Find(key);
            if (result == null)
            {
                return NotFound();
            }

            patch.Put(result);

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

            return Updated(result);
        }
        // PUT: odata/IdentityBinderLinkHistory(5)
        public async Task<IHttpActionResult> Put([FromODataUri] long key, Delta<IdentityBinderLinkHistory> patch)
        {
            Validate(patch.GetEntity());

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

            IdentityBinderLinkHistory identityBinderLinkHistory = await db.IdentityBinderLinkHistory.FindAsync(key);
            if (identityBinderLinkHistory == null)
            {
                return NotFound();
            }

            patch.Put(identityBinderLinkHistory);

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

            return Updated(identityBinderLinkHistory);
        }
        // PUT: odata/Programs(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<Program> patch)
        {
            Validate(patch.GetEntity());

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

            Program program = db.Programs.Find(key);
            if (program == null)
            {
                return NotFound();
            }

            patch.Put(program);

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

            return Updated(program);
        }
        // PUT: odata/BOOKs(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<BOOK> patch)
        {
            Validate(patch.GetEntity());

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

            BOOK bOOK = db.BOOKS.Find(key);
            if (bOOK == null)
            {
                return NotFound();
            }

            patch.Put(bOOK);

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

            return Updated(bOOK);
        }
        // PUT: odata/TauschObjs(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<TauschObj> patch)
        {
            Validate(patch.GetEntity());

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

            TauschObj tauschObj = db.TauschObjs.Find(key);
            if (tauschObj == null)
            {
                return NotFound();
            }

            patch.Put(tauschObj);

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

            return Updated(tauschObj);
        }
        // PUT: odata/Members(5)
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<Member> patch)
        {
            Validate(patch.GetEntity());

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

            Member member = await db.Members.FindAsync(key);
            if (member == null)
            {
                return NotFound();
            }

            patch.Put(member);

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

            return Updated(member);
        }
        // PUT: odata/ODMatchHistoryDetails(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<MatchHistoryDetail> patch)
        {
            Validate(patch.GetEntity());

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

            MatchHistoryDetail matchHistoryDetail = db.MatchHistoryDetails.Find(key);
            if (matchHistoryDetail == null)
            {
                return NotFound();
            }

            patch.Put(matchHistoryDetail);

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

            return Updated(matchHistoryDetail);
        }
        public IHttpActionResult Put([FromODataUri] int key,  Delta<DeltaEnumCustomer> entity)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            DeltaEnumCustomer customer = GetCustomers().FirstOrDefault(e => e.Id == key);
            if (customer == null)
            {
                return NotFound();
            }

            entity.Put(customer);
            return Updated(customer);
        }
        // PUT: odata/ODVirus(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<Virus> patch)
        {
            Validate(patch.GetEntity());

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

            Virus virus = db.Viruses.Find(key);
            if (virus == null)
            {
                return NotFound();
            }

            patch.Put(virus);

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

            return Updated(virus);
        }
        // PUT: odata/ODAspNetRoles(5)
        public IHttpActionResult Put([FromODataUri] string key, Delta<AspNetRole> patch)
        {
            Validate(patch.GetEntity());

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

            AspNetRole aspNetRole = db.AspNetRoles.Find(key);
            if (aspNetRole == null)
            {
                return NotFound();
            }

            patch.Put(aspNetRole);

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

            return Updated(aspNetRole);
        }
        // PUT: odata/Employees(5)
        public IHttpActionResult Put([FromODataUri] long key, Delta<Employee> patch)
        {
            Validate(patch.GetEntity());

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

            Employee employee = db.Employees.Find(key);
            if (employee == null)
            {
                return NotFound();
            }

            patch.Put(employee);

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

            return Updated(employee);
        }
        // PUT: odata/ShoppingLists(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<ShoppingList> patch)
        {
            Validate(patch.GetEntity());

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

            ShoppingList shoppingList = db.ShoppingList.Find(key);
            if (shoppingList == null)
            {
                return NotFound();
            }

            patch.Put(shoppingList);

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

            return Updated(shoppingList);
        }
        // PUT: odata/MsrRecurringQueries(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<MsrRecurringQuery> patch)
        {
            Validate(patch.GetEntity());

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

            MsrRecurringQuery msrRecurringQuery = db.MsrRecurringQueries.Find(key);
            if (msrRecurringQuery == null)
            {
                return NotFound();
            }

            patch.Put(msrRecurringQuery);

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

            return Updated(msrRecurringQuery);
        }
Exemple #23
0
        public void Put_UnRelatedType_Throws_InvalidOp()
        {
            // Arrange
            Delta<Base> delta = new Delta<Base>(typeof(Derived));
            AnotherDerived unrelatedEntity = new AnotherDerived();

            // Act & Assert
            Assert.Throws<InvalidOperationException>(
                () => delta.Put(unrelatedEntity),
                "Cannot use Delta of type 'System.Web.Http.OData.DeltaTest+Derived' on an entity of type 'System.Web.Http.OData.DeltaTest+AnotherDerived'.");
        }
Exemple #24
0
        public void Put_DoesNotClear_PropertiesNotOnEntityType()
        {
            // Arrange
            dynamic delta = new Delta<Base>(typeof(Derived));
            delta.DerivedInt = 24;
            DerivedDerived derived = new DerivedDerived { BaseInt = 42, DerivedInt = 0, BaseString = "42", DerivedString = "42", DerivedDerivedInt = 42, DerivedDerivedString = "42" };

            // Act
            delta.Put(derived);

            // Assert
            Assert.Equal("42", derived.DerivedDerivedString);
            Assert.Equal(42, derived.DerivedDerivedInt);
        }
Exemple #25
0
        public void Put_Clears_DerivedTypeProperties()
        {
            // Arrange
            dynamic delta = new Delta<Base>(typeof(Derived));
            delta.DerivedInt = 24;
            Derived derived = new Derived { BaseInt = 42, DerivedInt = 0, BaseString = "42", DerivedString = "42" };

            // Act
            delta.Put(derived);

            // Assert
            Assert.Equal(24, derived.DerivedInt);
            Assert.Equal(0, derived.BaseInt);
            Assert.Null(derived.BaseString);
            Assert.Null(derived.DerivedString);
        }
        // PUT: odata/Usuarios(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<Usuario> patch)
        {
            Validate(patch.GetEntity());

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

            Usuario usuario = db.Usuario.Find(key);
            if (usuario == null)
            {
                return NotFound();
            }

            patch.Put(usuario);

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

            return Updated(usuario);
        }
        // PUT: odata/ODFriends(5)
        public IHttpActionResult Put([FromODataUri] string key, Delta<Friend> patch)
        {
            Validate(patch.GetEntity());

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

            Friend friend = db.Friends.Find(key);
            if (friend == null)
            {
                return NotFound();
            }

            patch.Put(friend);

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

            return Updated(friend);
        }