Ejemplo n.º 1
0
        public TMSArea Add(TMSAreaCreateViewModel Vm)
        {
            var entity = _mapper.Map <TMSAreaCreateViewModel, TMSArea>(Vm);

            _itmsAreaRepository.Add(entity);
            SaveChanges();
            return(entity);
        }
Ejemplo n.º 2
0
        public IActionResult Add([FromBody] TMSAreaCreateViewModel Vm)
        {
            if (!ModelState.IsValid)
            {
                var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                return(new BadRequestObjectResult(new GenericResult(false, allErrors)));
            }
            else
            {
                try
                {
                    _tmsAreaService.Add(Vm);

                    return(new OkObjectResult(new GenericResult(true, "Add success!!!")));
                }
                catch (Exception ex)
                {
                    return(new OkObjectResult(new GenericResult(false, ex.Message)));
                }
            }
        }