Example #1
0
        public IActionResult Post([FromBody] ClientSBTViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var newClient = _mapper.Map <ClientSBTViewModel, ClientSBT>(model);


                    _repository.AddEntity(newClient);



                    if (_repository.SaveAll())
                    {
                        return(Created($"/api/ClientSBTs/{newClient.SBT}", _mapper.Map <ClientSBT, ClientSBTViewModel>(newClient)));
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Failed to save a new client: {ex}");
            }

            return(BadRequest("Failed to save new client"));
        }
Example #2
0
 public void AddDto(ProjectDto dto)
 {
     _projectRepository.AddEntity(Mapper.Map <Project>(dto));
 }