public async Task <ActionResult <CampModel> > Put( [FromServices] IMonikerSettings monikerSettings, [FromServices] IMonikerRuleProcessor monikerRuleProcessor, string moniker, CampModel model) { try { if (!monikerSettings.PutEnabled) { return(this.StatusCode(StatusCodes.Status403Forbidden, "Update disable on API...")); } var checkResults = await monikerRuleProcessor.PassesAllRulesAsync(model); if (!checkResults.Passed) { return(this.StatusCode(StatusCodes.Status406NotAcceptable, checkResults.Errors)); } var oldCamp = await _repository.GetCampAsync(moniker); if (oldCamp == null) { return(NotFound($"Could not find camp with moniker of {moniker}")); } _mapper.Map(model, oldCamp); if (await _repository.SaveChangesAsync()) { return(_mapper.Map <CampModel>(oldCamp)); } } catch (Exception e) { _logger.LogError(e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public AlphaNumericNameRule(IMonikerSettings configuration) { _configuration = configuration; }
public UpperCaseNameRule(IMonikerSettings configuration) { _configuration = configuration; }