public IActionResult GetUserById(int id) { HttpStatusCode statusCode = HttpStatusCode.OK; ResponseUsers response = new ResponseUsers(); try { response.Usuarios.Add(_users.GetUserById(id)); } catch (UserException e) { statusCode = HttpStatusCode.NotFound; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogInformation(e, $"User with id {id.ToString()} not found"); } catch (Exception e) { statusCode = HttpStatusCode.InternalServerError; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogError(e, $"Failed to get user with id {id.ToString()}"); } return(StatusCode((int)statusCode, response)); }
public IActionResult GetAllUsers() { HttpStatusCode statusCode = HttpStatusCode.OK; ResponseUsers response = new ResponseUsers(); try { response.Usuarios = _users.GetAllUsers(); } catch (DatabaseException e) { statusCode = HttpStatusCode.InternalServerError; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogError(e, $"Failed to get list user"); } catch (Exception e) { statusCode = HttpStatusCode.InternalServerError; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogError(e, $"Failed to get list user"); } return(StatusCode((int)statusCode, response)); }
public IActionResult GetUserByidentification(string identification) { HttpStatusCode statusCode = HttpStatusCode.OK; ResponseUsers response = new ResponseUsers(); try { if (!string.IsNullOrEmpty(identification)) { response.Usuarios.Add(_users.GetUserByIdentification(identification)); } else { statusCode = HttpStatusCode.BadRequest; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = "Datos invalidos"; } } catch (UserException e) { statusCode = HttpStatusCode.NotFound; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogInformation(e, $"User with identification {identification} not found"); } catch (Exception e) { statusCode = HttpStatusCode.InternalServerError; response.StatusCode = (int)statusCode; response.IsSucessfull = false; response.ErrorMessage = e.Message; _logger.LogError(e, $"Failed to get user with identification {identification}"); } return(StatusCode((int)statusCode, response)); }
public void ResponseInfoReceieved(DataInfo dataInfo) { ResponseInfo responseInfo = (ResponseInfo)dataInfo; Debug.Log("Ответ: " + responseInfo.responseType); switch (responseInfo.responseType) { case ResponseInfo.ResponseType.VisitedOK: SyncContext.RunOnUnityThread(() => Links.ToastController.Show("Посещение засчитано!")); break; case ResponseInfo.ResponseType.ResponseString: ResponseString responseString = (ResponseString)responseInfo; SyncContext.RunOnUnityThread(() => Links.MainMenuController.QRlayout.ShowLayout(responseString.String)); break; case ResponseInfo.ResponseType.AutorizationOk: SyncContext.RunOnUnityThread(Links.LoginLayoutController.OpenMainMenu); break; case ResponseInfo.ResponseType.ResponseUserInfo: ResponseUser tmp = (ResponseUser)responseInfo; if (tmp.responseUserType == ResponseUser.ResponseUserType.PurchaseOk) { Links.DeviceInformation.PlayerData = tmp.data; //TODO //Отрисовать купленный предмет return; } if (tmp.responseUserType == ResponseUser.ResponseUserType.DescriptionUpdate) { //Обновить описание!!! //TODO //Links.DeviceInformation.PlayerData.Description = "" Links.DeviceInformation.PlayerData = tmp.data; return; } Links.DeviceInformation.PlayerData = tmp.data; Links.LoginLayoutController.OpenMainMenu(); break; case ResponseInfo.ResponseType.AutorizationFalied_WrongLogin: SyncContext.RunOnUnityThread(() => Links.LoginLayoutController.OpenLoginLayoutWithError("Wrong login!")); break; case ResponseInfo.ResponseType.AutorizationFailed_WrongPassword: SyncContext.RunOnUnityThread(() => Links.LoginLayoutController.OpenLoginLayoutWithError("Wrong password!")); break; case ResponseInfo.ResponseType.RegistartionFailed_ExistLogin: SyncContext.RunOnUnityThread(() => Links.LoginLayoutController.OpenRegisterWithError("Login already exists!")); break; case ResponseInfo.ResponseType.ResponseEvents: //события на которые записан пользователь //TODO //actual: все события ResponseUserEvent responseUserEvent = (ResponseUserEvent)responseInfo; //responseUserEvent.data[0].visited (не визит а записан) Links.DeviceInformation.PlayerEvents = responseUserEvent.data; SyncContext.RunOnUnityThread(() => Links.EventsLayout.UpdateList(responseUserEvent.data)); break; case ResponseInfo.ResponseType.ResponseUsers: ResponseUsers response = (ResponseUsers)responseInfo; switch (response.usersType) { case ResponseUsers.UsersType.Name: SyncContext.RunOnUnityThread(() => Links.FindUserLayout.UpdateList(response.players)); break; case ResponseUsers.UsersType.Rating: SyncContext.RunOnUnityThread(() => Links.TopPlayersLayout.UpdateTop(response.players)); break; } break; case ResponseInfo.ResponseType.ResponseUserEvents: //не Все предстоящие события (хз вообще что это) ResponseEvent responseEvent = (ResponseEvent)responseInfo; Links.DeviceInformation.FutureEvents = responseEvent.data; //SyncContext.RunOnUnityThread(() => Links.EventsLayout.UpdateList(responseEvent.data)); break; case ResponseInfo.ResponseType.ResponseMainInfo: //Серверное время ResponseMainInfo mainInfo = (ResponseMainInfo)responseInfo; SyncContext.RunOnUnityThread(() => Links.CurrentPlayerGameManagerScript.ResponseMainInfo(mainInfo)); break; case ResponseInfo.ResponseType.ResponseCastle: ResponseCastle responsedCastle = (ResponseCastle)responseInfo; SyncContext.RunOnUnityThread(() => Links.LastOpenedCastle.CastleResponse(responsedCastle)); break; case ResponseInfo.ResponseType.ResponseReviews: ResponseReviews responsedReviews = (ResponseReviews)responseInfo; if (responsedReviews.responseReviewsType == ResponseReviews.ResponseReviewsType.CastleReviews) { SyncContext.RunOnUnityThread(() => Links.LastOpenedCastle.CastleHistoryResponse(responsedReviews)); } if (responsedReviews.responseReviewsType == ResponseReviews.ResponseReviewsType.EventReviews) { Links.MainMenuController.CommentsLayout.GetComponent <CommentsLayout>() .ShowComments(responsedReviews.reviews); } break; case ResponseInfo.ResponseType.ResponseUpdate: ResponseUpdate responsedUpdate = (ResponseUpdate)responseInfo; switch (responsedUpdate.responseUpdateType) { case ResponseUpdate.ResponseUpdateType.UpdateEventReviews: //TODO //TODO ResponseReviews reviews = (ResponseReviews)responsedUpdate.updatingData; //обновить список комментов! //reviews.reviews break; case ResponseUpdate.ResponseUpdateType.UpdateCastleReviews: SyncContext.RunOnUnityThread(() => Links.LastOpenedCastle.CastleUpdateResponse(responsedUpdate)); break; } break; } }