Beispiel #1
0
        // POST: odata/Thefts
        public async Task <IHttpActionResult> Post(Theft thefts)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Theft.Add(thefts);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TheftsExists(thefts.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(thefts));
        }
Beispiel #2
0
 public void Setup()
 {
     _dice          = new Dice();
     _theft         = new Theft();
     _player        = new TestPlayer(StartMoney);
     _squareActions = new BoardCursor(
         new Board(),
         new PlayerCursor(
             new List <Player>
     {
         _player,
     },
             _dice));
 }
Beispiel #3
0
        // DELETE: odata/Thefts(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            Theft thefts = await db.Theft.FindAsync(key);

            if (thefts == null)
            {
                return(NotFound());
            }

            db.Theft.Remove(thefts);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        // PUT: odata/Thefts(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <Theft> patch)
        {
            Validate(patch.GetEntity());

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

            Theft thefts = await db.Theft.FindAsync(key);

            if (thefts == null)
            {
                return(NotFound());
            }

            patch.Put(thefts);

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

            return(Updated(thefts));
        }