Пример #1
0
        public async Task <ActionResult <DivisionDto> > CreateDivision(CreateDivisionDto createDivision)
        {
            var division = this.mapper.MapTo <Division, CreateDivisionDto>(createDivision);

            var newDivision = await this.service.CreateDivision(division);

            var dto = this.mapper.MapTo <DivisionDto, Division>(newDivision);

            return(Ok(dto));
        }
Пример #2
0
        public async Task DivisionShouldBeAdded()
        {
            await RunWithinTransactionAndRollBack(async (client) =>
            {
                var divisionToAdd = new CreateDivisionDto
                {
                    Name         = "New",
                    OriginalName = "Division",
                    Director     = "John Doe"
                };

                var payload             = Serialize(divisionToAdd);
                var divisionAddResponse = await client.PostAsync("api/divisions", payload);
                var division            = await DeserializeAsAsync <DivisionDto>(divisionAddResponse.Content);


                Assert.AreEqual(divisionToAdd.Name, division.Name);
                Assert.AreEqual(divisionToAdd.OriginalName, division.OriginalName);
                Assert.AreEqual(divisionToAdd.Director, division.Director);
                Assert.AreNotEqual(default(int), division.Id);
            });
        }