public void Create(ConfigurationSite configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } //Se inactivan las configuraciones anteriores y solo se deja activa la actual. InactiveAllRecords(); _context.ConfigurationSites.Add(configuration); }
public async Task <ActionResult <ConfigurationSiteDto> > GetConfiguration(Guid id) { ConfigurationSite configuration = null; await Task.Run(() => { configuration = _configurationService.GetById(id); }); if (configuration == null) { return(NotFound()); } return(_mapper.Map <ConfigurationSiteDto>(configuration)); }
public async Task <ActionResult <ConfigurationSiteDto> > PostConfiguration(ConfigurationSiteCreateDto configurationSiteDto) { ConfigurationSite configuration = null; try { configuration = _mapper.Map <ConfigurationSite>(configurationSiteDto); configuration.Id = Guid.NewGuid(); configuration.Active = true; _configurationService.Create(configuration); await Task.Run(() => { _configurationService.SaveChanges(); }); } catch (DbUpdateException ex) { return(BadRequest(Utils.GenerateResponse(configurationSiteDto, null, System.Net.HttpStatusCode.BadRequest, ex.Message))); } return(CreatedAtAction("GetConfigurations", new { id = configuration.Id }, configuration)); }
public void Update(ConfigurationSite configuration) { _context.Entry(configuration).State = Microsoft.EntityFrameworkCore.EntityState.Modified; }