Ejemplo n.º 1
0
        public async Task InsertActorTestAsync(string firstname, string lastname, bool expectedSuccess,
                                               int expectedActorId, int expectedCountAfter)
        {
            const int expectedCountBefore = 25;
            var       actor = new Actor {
                Firstname = firstname, Lastname = lastname
            };

            var actors = await actorLogic.FindAllAsync();

            Assert.Equal(expectedCountBefore, actors.Count());

            var status = await actorLogic.InsertAsync(actor);

            Assert.Equal(expectedActorId, actor.ActorId);
            Assert.Equal(expectedCountAfter, actors.Count());
            Assert.Equal(expectedSuccess, status);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Insert([FromBody] Actor data)
        {
            try
            {
                if (await actorLogic.InsertAsync(data))
                {
                    return(CreatedAtAction(nameof(Get), new { id = data.ActorId }, data));
                }

                return(BadRequest("Error creating the resource!"));
            }
            catch (ArgumentException)
            {
                return(Conflict(data));
            }
        }