Esempio n. 1
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta<UserTask> patch)
        {
            Validate(patch.GetEntity());

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

            UserTask userTask = db.Tasks.Find(key);
            if (userTask == null)
            {
                return NotFound();
            }

            patch.Patch(userTask);

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

            return Updated(userTask);
        }
        // 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/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);
        }
Esempio n. 4
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);
        }
        public IHttpActionResult Patch([FromODataUri] int key, Delta<MatchHistory> patch)
        {
            Validate(patch.GetEntity());

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

            MatchHistory matchHistory = db.MatchHistories.Find(key);
            if (matchHistory == null)
            {
                return NotFound();
            }

            patch.Patch(matchHistory);

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

            return Updated(matchHistory);
        }
        // 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] 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] 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);
        }
Esempio n. 9
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);
        }
        // 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/CATEGORies(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta<CATEGORY> patch)
        {
            Validate(patch.GetEntity());

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

            CATEGORY cATEGORY = db.CATEGORies.Find(key);
            if (cATEGORY == null)
            {
                return NotFound();
            }

            patch.Put(cATEGORY);

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

            return Updated(cATEGORY);
        }
        // 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/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);
        }
Esempio n. 14
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);
        }
        public IHttpActionResult Patch([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.Patch(customer);

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

            return Updated(customer);
        }
        // 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);
        }
        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);
        }
Esempio n. 18
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/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);
        }
Esempio n. 20
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);
        }
        // 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/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([FromODataUri] int key, Delta<ODataTodoItem> delta) {
      var todoItem = delta.GetEntity();
      Validate(todoItem);

      if (!ModelState.IsValid) {
        return BadRequest(ModelState);
      }
      lock (_locker)
      {
         _todoItem.Description = todoItem.Description;
      }
      return Updated(todoItem);
    }
Esempio n. 24
0
        // PUT: odata/GeoCaches
        public async Task<IHttpActionResult> Put([FromODataUri] int key, Delta<GeoCache> delta)
        {
            Validate(delta.GetEntity());

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

            var _geoCache = delta.GetEntity();
            var geoCache = new Calico.GIS.Models.GeoCache
            {
                Id = _geoCache.Id,
                Latitude = _geoCache.Latitude,
                Longitude = _geoCache.Longitude,
                Name = _geoCache.Name
            };

            GeoCacheService.UpdateGeoCache(geoCache);

            return Updated(geoCache);

        }
        public IHttpActionResult Patch([FromODataUri] string key, Delta<StockDeal> delta)
        {
            Validate(delta.GetEntity());

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

            // TODO: Get the entity here.

            // delta.Patch(stockDeal);

            // TODO: Save the patched entity.

            // return Updated(stockDeal);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
        public IHttpActionResult Patch([FromODataUri] System.Guid key, Delta<ProductViewModel> delta)
        {
            Validate(delta.GetEntity());

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

            // TODO: Get the entity here.

            // delta.Patch(productViewModel);

            // TODO: Save the patched entity.

            // return Updated(productViewModel);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
        // PUT: NewsOdata/GettingNewsUsingHeaderValue(5)
        public IHttpActionResult Put([FromODataUri] long key, Delta<NewsInfrastructure.News> delta)
        {
            Validate(delta.GetEntity());

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

            // TODO: Get the entity here.

            // delta.Put(news);

            // TODO: Save the patched entity.

            // return Updated(news);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
Esempio n. 28
0
        public void CanCreateDeltaOfDerivedTypes()
        {
            var delta = new Delta <Base>(typeof(Derived));

            Assert.IsType(typeof(Derived), delta.GetEntity());
        }
        public IHttpActionResult Patch([FromODataUri] long key, Delta<VELEMIMUNKAINMLIST> delta)
        {
            Validate(delta.GetEntity());

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

            // TODO: Get the entity here.

            // delta.Patch(vELEMIMUNKAINMLIST);

            // TODO: Save the patched entity.

            // return Updated(vELEMIMUNKAINMLIST);
            return StatusCode(HttpStatusCode.NotImplemented);
        }
Esempio n. 30
0
        // PUT: odata/WebUsers(5)
        public IHttpActionResult Put( [FromODataUri] int? key, Delta<WebUser> patch )
        {
            Validate( patch.GetEntity() );

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

            WebUser webUser = db.WebUserSet.Find( key );
            if ( webUser == null ) {
                return NotFound();
            }

            patch.Put( webUser );

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

            return Updated( webUser );
        }
        public async Task<IHttpActionResult> Patch([FromODataUri] String key, Delta<LifeCycle> delta)
        {
            var declaringType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
            var fn = String.Format("{0}:{1}",
                declaringType.Namespace,
                declaringType.Name);

            if (!ModelState.IsValid)
            {
                Debug.WriteLine("Entity to be changed by LifeCycleManager with id '{0}' has invalid ModelState.", key);
                return BadRequest(ModelState);
            }

            try
            {
                Debug.WriteLine(fn);

                var identity = CurrentUserDataProvider.GetIdentity(TenantId);

                var permissionId = CreatePermissionId("CanUpdate");
                if (!identity.Permissions.Contains(permissionId))
                {
                    return StatusCode(HttpStatusCode.Forbidden);
                }

                var entityUri = new Uri(key);
                var entity = LoadEntity(new DefaultAuthenticationProvider(), entityUri);
                var lifeCycleManager = new LifeCycleManager(new DefaultAuthenticationProvider(), ExtractTypeFromUriString(key));
                lifeCycleManager.RequestStateChange(entityUri, entity, delta.GetEntity().Condition, identity.Tid);

                return Ok();
            }
            catch (UriFormatException e)
            {
                return BadRequest("Invalid Id - Id has to be a valid URI");
            }
            catch (HttpRequestException e)
            {
                return BadRequest("Loading entity from passed Uri failed (Either not found or not authorized)");
            }
            catch (InvalidOperationException e)
            {
                return BadRequest(String.Format("Chaning state with provided condition: '{0}' not possible", delta.GetEntity().Condition));
            }
            catch (Exception e)
            {
                Debug.WriteLine(String.Format("{0}: {1}\r\n{2}", e.Source, e.Message, e.StackTrace));
                throw;
            }
        }