/// <summary> /// /// </summary> /// <param name="name"></param> /// <returns></returns> public ProfileInfoContract GetProfileInfoByName(string name) { var response = new ResponseService(); response.statusCode = 0; response.statusDescription = string.Empty; var user = userRepository.GetUserByName(name); if (user != null) { response.statusCode = 200; response.statusDescription = "OK"; } else { response.statusCode = 404; response.statusDescription = "Not Found"; } return new ProfileInfoContract { userId = user.userId, userName = user.userName, name = user.profile.name, email = user.email, avatar = user.profile.avatar, dateCreated = DateTime.Now, karma = user.profile.karma, response = response }; }
/// <summary> /// check available balance /// </summary> /// <param name="uid"></param> /// <returns></returns> public ResponseService CheckBalance(Guid uid) { decimal taskCost = 5; Account account = userRepository.GetUserById(uid).account; ResponseService result = new ResponseService(); if (account.balance < taskCost) { result.statusCode = 500; result.statusDescription = "failed"; } else { result.statusCode = 200; result.statusDescription = "ok"; } return result; }