asp.net web api - Web API, C#, Json Objects, Views -
i have issues displaying data json object in asp.net web api project. first try, don't have views, gonna use postman testing. can give me diretions how display model json object?
//usercontroller public class userscontroller : apicontroller { private learntolearncontext db = new learntolearncontext(); private baserepository<users> _repository = null; public userscontroller() { this._repository = new baserepository<users>(); } // get: api/users [responsetype(typeof(users))] public ihttpactionresult getusers() { var user = _repository.getall(); var bindingmodel = mapper.map<usersbindingmodels>(user); return ok(bindingmodel); } } //usermodel public class users { [key] public int id { get; set; } [required] public string name { get; set; } [unique] [required] public string email { get; set; } [required] public string password { get; set; } public bool isteacher { get; set; } public virtual list<courses> courses { get; set; } } //userbindingmodel public class usersbindingmodels { [required] public string name { get; set; } [unique] [required] public string email { get; set; } [required] public string password { get; set; } public bool isteacher { get; set; } public virtual list<courses> courses { get; set; } }
Comments
Post a Comment