enum in c#
enum in c#
public enum UserType
{
Admin,
Manager,
Employee
}
public class ProfileResponse
{
public long id { get; set; }
public long user_id { get; set; }
public string first_name { get; set; }
public int userType { get; set; }
}
Profile profile = Db.GetBy<Profile>(x => x.userId == user_id);
var response = new ProfileResponse();
response.id = profile.id;
response.user_id = profile.userId;
response.first_name = profile.firstName;
response.userType = getUserType(profile.userId);
public int getUserType(long userId)
{
int type = 0;
var user = (from u in Db.Users where u.id == userId select u.Type).FirstOrDefault();
if (user == UserType.Admin)
{
type = 0;
}
else if (user == UserType.Manager)
{
type = 1;
}
else if (user == UserType.Employee)
{
type = 2;
}
return type;
}
No comments:
Post a Comment