public IActionResult GetByID(uint avartarId) { var api = Api.INSTANCE; using (var da = api.DAFactory.Get()) { var avatar = da.Avatars.Get(avartarId); if (avatar == null) { return(ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"))); } var avatarJson = new JSONAvatar { avatar_id = avatar.avatar_id, shard_id = avatar.shard_id, name = avatar.name, gender = avatar.gender, date = avatar.date, description = avatar.description, current_job = avatar.current_job, mayor_nhood = avatar.mayor_nhood }; return(ApiResponse.Json(HttpStatusCode.OK, avatarJson)); } }
public IActionResult GetByName(int shardId, string name) { var api = Api.INSTANCE; using (var da = api.DAFactory.Get()) { var avatar = da.Avatars.SearchExact(shardId, name, 1).FirstOrDefault(); if (avatar == null) { return(ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"))); } var avatarJson = new JSONAvatar(); var avatarById = da.Avatars.Get(avatar.avatar_id); if (avatarById == null) { return(ApiResponse.Json(HttpStatusCode.NotFound, new JSONAvatarError("Avatar not found"))); } avatarJson = (new JSONAvatar { avatar_id = avatarById.avatar_id, shard_id = avatarById.shard_id, name = avatarById.name, gender = avatarById.gender, date = avatarById.date, description = avatarById.description, current_job = avatarById.current_job, mayor_nhood = avatarById.mayor_nhood }); return(ApiResponse.Json(HttpStatusCode.OK, avatarJson)); } }