示例#1
0
        public IActionResult AddAddressType(AddressTypeViewModel addresstypeVm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _addTypeRepo.AddAddressType(addresstypeVm.ReverseMap());

            var addressType = _addTypeRepo.GetAddressType(addresstypeVm.ID);

            AddressTypeViewModel addTypeVM = new AddressTypeViewModel();

            addTypeVM.MapSingleAddressType(addressType);

            CreatedAtRouteResult response = CreatedAtRoute("GetAddressType", new { controller = "AddressTypes", id = addTypeVM.ID }, addTypeVM);

            return(response);
        }