public BaseResponse <YachtAttributeViewModel> FindByNameAsync(string attributeName) { var entity = _context.YachtAttributes.FirstOrDefault(p => p.AttributeName.Equals(attributeName)); if (entity != null) { var viewModel = new YachtAttributeViewModel(); viewModel.InjectFrom(entity); return(BaseResponse <YachtAttributeViewModel> .Success(viewModel)); } else { return(BaseResponse <YachtAttributeViewModel> .NoContent(new YachtAttributeViewModel())); } }
public async Task <BaseResponse <YachtAttributeViewModel> > FindByIdAsync(int id) { var entity = await _context.YachtAttributes.FindAsync(id); if (entity != null) { var viewModel = new YachtAttributeViewModel(); viewModel.InjectFrom(entity); return(BaseResponse <YachtAttributeViewModel> .Success(viewModel)); } else { return(BaseResponse <YachtAttributeViewModel> .BadRequest()); } }