public static UserModel GetById(int id) { UserModel userModel = null; var userDao = new MSSQLUserDAO(); try { var userDb = userDao.GetUserById(id); if (userDb != null) { userModel = new UserModel(); userModel.Id = userDb.Id; userModel.FirstName = userDb.FirstName; userModel.LastName = userDb.LastName; userModel.Login = userDb.Login; userModel.Password = userDb.Password; } } catch (NoDatasourceConnectionException e) { Debug.WriteLine(e.Message); throw new DataServiceException(); } return(userModel); }
public new static StudentModel GetById(int id) { StudentModel studentModel = null; var userDao = new MSSQLUserDAO(); try { var userDb = userDao.GetUserById(id); if (userDb != null) { if (Enum.Parse <User.UserType>(userDb.Type.ToUpper()).Equals(User.UserType.STUDENT)) { studentModel = new StudentModel(); studentModel.Id = userDb.Id; studentModel.FirstName = userDb.FirstName; studentModel.LastName = userDb.LastName; studentModel.Login = userDb.Login; studentModel.Password = userDb.Password; studentModel.FieldOfStudy = userDb.FieldOfStudy; studentModel.FacultySymbol = userDb.FacultySymbol; studentModel.IndexNumber = userDb.IndexNumber; } } }catch (NoDatasourceConnectionException e) { Debug.WriteLine(e.Message); throw new DataServiceException(); } return(studentModel); }