示例#1
0
        public async Task <ActionResult> Delete(string key, Auction auction)
        {
            var existing = await _auctionContext.GetByKeyAsync(key);

            if (null == existing)
            {
                return(this.NotFound($"{key} not found!"));
            }

            if (this.IsAdministrator())
            {
                await _adminAuctionQuery.Delete(key);
            }
            else
            {
                await _userAuctionQuery.Delete(key);
            }
            return(this.Ok(JsonConvert.SerializeObject(new FirebaseObject <Auction>(key, auction))));
        }
        public async void CreateReadUpdateDelete()
        {
            //Post
            var person     = _fixture.PersonList.ElementAt(3);
            var postResult = await _adminControllerQueryEntity.Post(person);

            Assert.NotNull(postResult);
            Assert.IsType <FirebaseObject <MockFirebasePerson> >(postResult);
            Assert.Equal(person.Name, postResult.Object.Name);

            //Get
            var getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.NotNull(getResult);
            Assert.IsType <MockFirebasePerson>(getResult);
            Assert.Equal(person.Name, getResult.Name);

            //Put
            person.Name = "Johnathan Doe";
            person.Age  = 25;
            var putResult = await _adminControllerQueryEntity.Put(postResult.Key, person);

            Assert.NotNull(putResult);
            Assert.IsType <MockFirebasePerson>(putResult);

            getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.NotNull(getResult);
            Assert.IsType <MockFirebasePerson>(getResult);
            Assert.Equal(person.Name, getResult.Name);
            Assert.Equal(person.Age, getResult.Age);
            Assert.Equal(person.Gender, getResult.Gender);

            //Delete
            await _adminControllerQueryEntity.Delete(postResult.Key);

            getResult = await _adminControllerQueryEntity.Get(postResult.Key);

            Assert.Null(getResult);
        }