public userdto GetUser(string email) { //if (!ModelState.IsValid) //{ // InvalidModelStateResult test = BadRequest(ModelState); // return BadRequest(ModelState); //} userdto dto = null; try { ApplicationUser user = db.Users.Where(u => u.UserName == email).SingleOrDefault(); dto = new userdto() { level = user.skillLevel, timesCaptain = user.timesCaptain, Name = user.UserName, isFrozen = user.bFreezeDB, Email = user.Email }; } catch (Exception e) { int mm = 0; } return(dto); }
public IEnumerable <userdto> GetUsers() { //if (!ModelState.IsValid) //{ // InvalidModelStateResult test = BadRequest(ModelState); // return BadRequest(ModelState); //} userdto dto = null; List <userdto> info = new List <userdto>(); try { List <ApplicationUser> users = UserManager.Users.ToList(); foreach (ApplicationUser user in users) { dto = new userdto() { level = user.skillLevel, timesCaptain = user.timesCaptain, Email = user.Email, PhoneNumber = user.PhoneNumber }; info.Add(dto); } } catch (Exception e) { int mm = 0; } return(info); }
public List <MatchDTO> GetUserInfoforMonth(String email, int month) { //if (!ModelState.IsValid) //{ // InvalidModelStateResult test = BadRequest(ModelState); // return BadRequest(ModelState); //} userdto dto = null; List <MatchDTO> dtos = new List <MatchDTO>(); try { ApplicationUser user = db.Users.Include(m => m.Matches).Where(u => u.Email == email).SingleOrDefault(); // dto = new userdto() // { // level = user.skillLevel, // timesCaptain = user.timesCaptain, // Name = user.UserName, // Email = user.Email // }; // dto.matchs = new List<MatchDTO>(); foreach (Match match in user.Matches) { if (match.month != month) { continue; } MatchDTO matchdto = new MatchDTO(); matchdto.day = match.day; matchdto.month = match.month; matchdto.level = match.skillLevel; matchdto.Captain = match.captain; matchdto.players = new List <String>(); for (int i = 0; i < match.players.Count; i++) { // matchdto.players = matchdto.players + match.players[i].Email + ','; matchdto.players.Add(match.players[i].Email); } dtos.Add(matchdto); } } catch (Exception e) { int mm = 0; } return(dtos); }