Ejemplo n.º 1
1
        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);
        }
Ejemplo n.º 2
0
        public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Report> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Report report = await db.Reports.FindAsync(key);
            if (report == null)
            {
                return NotFound();
            }

            patch.Patch(report);

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

            return Updated(report);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        // 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);
        }
        public IHttpActionResult Patch([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.Patch(friend);

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

            return Updated(friend);
        }
Ejemplo n.º 6
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Login> patch)
        {
            Validate(patch.GetEntity());

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

            Login login = db.LoginSet.Find(key);
            if (login == null)
            {
                return NotFound();
            }

            patch.Patch(login);

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

            return Updated(login);
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta<SpecialAbility> patch)
        {
            Validate(patch.GetEntity());

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

            SpecialAbility specialAbility = db.SpecialAbilities.Find(key);
            if (specialAbility == null)
            {
                return NotFound();
            }

            patch.Patch(specialAbility);

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

            return Updated(specialAbility);
        }
Ejemplo n.º 8
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Ayle> patch)
        {
            Validate(patch.GetEntity());

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

            Ayle ayle = db.Ayle.Find(key);
            if (ayle == null)
            {
                return NotFound();
            }

            patch.Patch(ayle);

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

            return Updated(ayle);
        }
Ejemplo n.º 9
0
        // 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);
        }
        public IHttpActionResult Patch(Delta<SampleModel> delta)
        {
            // Using the Patch method on Delta<T>, will only overwrite only the properties whose value has
            // changed.
            var model = new SampleModel();
            delta.Patch(model);

            // Using Delta doesn't invoke validation on the values that are provided, so use the Validate method
            // on the model object after patching to validate it.
            this.Validate(model);
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var builder = new StringBuilder();
            builder.AppendLine("Updated Properties:");

            foreach(var property in delta.GetChangedPropertyNames())
            {
                object value;
                delta.TryGetPropertyValue(property, out value);

                builder.AppendLine(String.Format("\t{0} : {1}", property, value));
            }

            return Text(builder.ToString());
        }
        // 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);
        }
Ejemplo n.º 12
0
        public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<WorkType> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            WorkType worktype = await db.WorkTypes.FindAsync(key);
            if (worktype == null)
            {
                return NotFound();
            }

            patch.Patch(worktype);

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

            return Updated(worktype);
        }
        public IHttpActionResult Patch([FromODataUri] string key, Delta<AspNetUserLogin> patch)
        {
            Validate(patch.GetEntity());

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

            AspNetUserLogin aspNetUserLogin = db.AspNetUserLogins.Find(key);
            if (aspNetUserLogin == null)
            {
                return NotFound();
            }

            patch.Patch(aspNetUserLogin);

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

            return Updated(aspNetUserLogin);
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Movie> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Movie movie = db.Movies.Find(key);
            if (movie == null)
            {
                return NotFound();
            }

            patch.Patch(movie);

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

            return Updated(movie);
        }
        public IHttpActionResult Patch([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.Patch(employee);

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

            return Updated(employee);
        }
        // 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/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);
        }
        public IHttpActionResult Patch([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.Patch(matchHistoryDetail);

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

            return Updated(matchHistoryDetail);
        }
        // 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);
        }
        public IHttpActionResult Patch([FromODataUri] string 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.Patch(customer);

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

            return Updated(customer);
        }
        public IHttpActionResult Patch([FromODataUri] string key, Delta<Ingredient> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Ingredient ingredient = db.Ingredients.Find(key);
            if (ingredient == null)
            {
                return NotFound();
            }

            patch.Patch(ingredient);

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

            return Updated(ingredient);
        }
Ejemplo n.º 22
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Categories> patch)
        {
            Validate(patch.GetEntity());

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

            Categories categories = db.Categories.Find(key);
            if (categories == null)
            {
                return NotFound();
            }

            patch.Patch(categories);

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

            return Updated(categories);
        }
Ejemplo n.º 23
0
        public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<TodoList> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            TodoList todolist = await db.TodoLists.FindAsync(key);
            if (todolist == null)
            {
                return NotFound();
            }

            patch.Patch(todolist);

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

            return Updated(todolist);
        }
Ejemplo n.º 24
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<Contact> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Contact contact = db.Contacts.Find(key);
            if (contact == null)
            {
                return NotFound();
            }

            patch.Patch(contact);

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

            return Updated(contact);
        }
        // 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/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);
        }
        public IHttpActionResult Patch([FromODataUri] Guid key, Delta<WorkTaskModel> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            WorkTaskModel workTaskModel = db.WorkTaskModels.Find(key);
            if (workTaskModel == null)
            {
                return NotFound();
            }

            patch.Patch(workTaskModel);

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

            return Updated(workTaskModel);
        }
Ejemplo n.º 28
0
        // 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/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);
        }
Ejemplo n.º 30
0
        public async Task<IHttpActionResult> Patch([FromODataUri] int key, Delta<Hazard> patch)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Hazard hazard = await db.Hazards.FindAsync(key);
            if (hazard == null)
            {
                return NotFound();
            }

            patch.Patch(hazard);

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

            return Updated(hazard);
        }
Ejemplo n.º 31
0
        public void CanCreateDeltaOfDerivedTypes()
        {
            var delta = new Delta <Base>(typeof(Derived));

            Assert.IsType(typeof(Derived), delta.GetEntity());
        }
Ejemplo n.º 32
0
        public virtual async Task <HttpResponseMessage> Patch([FromODataUri] TKey key, Delta <TEntity> patch)
        {
            TEntity patchedEntity = await PatchEntityAsync(key, patch);

            return(EntitySetControllerHelpers.PatchResponse <TEntity>(Request, patchedEntity));
        }
Ejemplo n.º 33
0
        public void Can_Declare_A_Delta_Of_An_AbstractClass()
        {
            Delta <AbstractBase> abstractDelta = null;

            Assert.Null(abstractDelta);
        }
Ejemplo n.º 34
0
        public virtual HttpResponseMessage Patch([FromODataUri] TKey key, Delta <TEntity> patch)
        {
            TEntity patchedEntity = PatchEntity(key, patch);

            return(EntitySetControllerHelpers.PatchResponse(Request, patchedEntity));
        }
Ejemplo n.º 35
0
 /// <summary>
 /// This method should be overridden to apply a partial update to an existing entity in the entity set.
 /// </summary>
 /// <param name="key">The entity key of the entity to update.</param>
 /// <param name="patch">The patch representing the partial update.</param>
 /// <returns>A <see cref="Task"/> that contains the updated entity when it completes.</returns>
 protected internal virtual Task <TEntity> PatchEntityAsync(TKey key, Delta <TEntity> patch)
 {
     throw EntitySetControllerHelpers.PatchEntityNotImplementedResponse(Request);
 }