TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed elbarbary
NA
1.6k
278.8k
How to convert User class object to json file when success l
Aug 30 2019 11:17 PM
problem
How to convert User class object to json file when success login ?
I need to convert user class object to json file represent status of login and data related as following ;
this is actually desired result :
{
"request_status" : {
"status" : "succeeded",
"code": 0,
"message" : "login succeeded!"
},
"user_data": {
"UserFullName" : "Admin",
"LoginTime" : "12:00"
},
"branches": [
{
"BranchCode" : "1",
"BranchName":"Baha"
}
]
}
What I
try
is
:
[HttpPost(Contracts.ApiRoutes.Login.PostUserLogin)]
public
IActionResult PostUserLogins(Users user)
{
int
LoginStatus = _AuthunticateService.PostUserLogin(user.UserName,user.Password ,
out
DataTable Branches,
out
string
errorMessage,
out
int
statusCode);
if
(LoginStatus == 0)
{
user.StatusCode = statusCode;
user.StatusText =
"succeeded"
;
user.MessageStatus =
"login succeeded!"
;
if
(Branches.Rows.Count > 0)
{
user.dtgetBranches = Branches;
}
user.LoginTime = DateTime.Now.ToString();
// How to convert user class after assign values to json result as script above diplay
}
}
public
class
Users
{
public
string
UserName {
get
;
set
; }
public
string
Password {
get
;
set
; }
public
string
MessageStatus {
get
;
set
; }
public
int
StatusCode {
get
;
set
; }
public
string
StatusText {
get
;
set
; }
public
string
IpAddress {
get
;
set
; }
public
string
BrowserInfo {
get
;
set
; }
public
DataTable dtgetBranches {
get
;
set
; }
public
string
LoginTime {
get
;
set
; }
}
How to convert user
class
object
to json format
as
above ?
Reply
Answers (
1
)
How to use SP in EF Core – Code First Approach
How to I get values of n numbers of table row input in asp?