public async Task <IList <Widget> > GetAll() //should probably return the operation result { var result = await _repository.Get(); if (result.Success) { return(result.Result); } else { return(new List <Widget>()); } }
public async Task <XOFFOperationResult> SeedIfEmpty() { try { var getWidgetsResult = await _repository.Get(); if (!getWidgetsResult.Success || !getWidgetsResult.Result.Any()) { var widgets = new List <Widget>(); for (int i = 0; i < 15; i++) { var guid = Guid.NewGuid(); widgets.Add(new Widget() { LocalId = guid, Name = guid.ToString() }); } _repository.Insert(widgets); } return(XOFFOperationResult.CreateSuccessResult("There are widgets saved")); } catch (Exception e) { return(XOFFOperationResult.CreateFailure(e.Message)); } }