Beispiel #1
0
        public IActionResult SaveEntity(DirectionViewModel directionVm)
        {
            if (!ModelState.IsValid)
            {
                IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(allErrors));
            }

            if (directionVm.Id == 0)
            {
                _directionService.Add(directionVm);
            }
            else
            {
                _directionService.Update(directionVm);
            }

            _directionService.Save();
            return(new OkObjectResult(directionVm));
        }