Last post Apr 29, 2020 03:27 PM by DA924
Apr 29, 2020 02:19 PM|alexi|LINK
public class GetUserDefaultsAPIController : Controller
private readonly ApplicationDbContext _context;
public GetUserDefaultsAPIController(ApplicationDbContext context)
_context = context;
public async Task<ActionResult<MyMVC.Models.UserDefaults>> GetDefaultsAPI()
int ProfileId = GetSelectedProfileIdfromCookie(); // custom function
var UserDefaultsModel = await _context.UserDefaults.FirstOrDefaultAsync(m => m.cId == ProfileId);
if (UserDefaultsModel == null)
return UserDefaultsModel ;
those, but it would be nice if I could do it first server-side so don't have to do this client side?
Apr 29, 2020 03:05 PM|bruce (sqlwork.com)|LINK
In the model you can use the [JsonIgnore] attribute to suppress fields, but it is better to create a response model that only has what you want.
Apr 29, 2020 03:27 PM|DA924|LINK
You can use a DTO.