public async Task AddFeature() { var featureName = "NormalName"; var features = await _securityData.AddFeature(featureName); var expected = _dbFaker.Features.Max(l => l.Id) + 1; Assert.AreEqual(ActionStatus.Success, features.Status); Assert.AreEqual(expected, features.Id); _mock.Verify(data => data.AddFeature(featureName), () => Times.Exactly(1)); }
public IActionResult AddFeature(HomeDB.Models.Feature feature) { try { _FeatureService.AddFeature(feature); return(CreatedAtAction("AddFeature", feature)); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> AddFeature(FeatureDto featureDto) { try { var feature = _mapper.Map <Feature>(featureDto); feature.Status = Status.Authorized; _featureService.AddFeature(feature); await _unitOfWork.Save(); return(Ok(feature)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> AddFeature([FromBody] string featureName) { var result = _securityService.AddFeature(featureName); return(Ok(await result)); }