Exemplo n.º 1
0
        public IActionResult CreateType([FromBody] CreateTypeRequest request)
        {
            Type type = new Type();

            type.Name     = request.Name;
            type.IsActive = true;
            _typeService.Add(type);
            return(Ok());
        }
Exemplo n.º 2
0
        public CreateTypeResponse Create(CreateTypeRequest request)
        {
            var response = new CreateTypeResponse();

            try
            {
                var type = request.MapTo <Data.Entities.Type>();
                DataContext.Types.Add(type);
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message   = "KPI type item has been added successfully";
            }
            catch (DbUpdateException dbUpdateException)
            {
                response.Message = dbUpdateException.Message;
            }

            return(response);
        }