Beispiel #1
0
        public async Task <IHttpActionResult> Post([FromBody] NationalityViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var newModel = Mapper.Map <NationalityViewModel, Nationality>(viewModel);

            newModel.CreateUser = newModel.UpdateUser = User.Identity.Name;
            _nationalityRepository.Add(newModel);
            await UnitOfWork.SaveChangesAsync();

            return(RedirectToRoute("", new { controller = "Nationality", id = newModel.Id }));
        }