Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,Description")] SalutationViewmodel vm)
        {
            if (ModelState.IsValid)
            {
                var Res = _Mapper.Map <Salutation>(vm);
                await _salutationRepository.SaveOrUpdateAsync(Res);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vm));
        }
Beispiel #2
0
        public IActionResult Create([FromBody] SalutationDTO dto)
        {
            var Res = _Mapper.Map <Salutation>(dto);

            try
            {
                var salutation = _salutationRepository.SaveOrUpdateAsync(Res);
                return(Ok(salutation));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }