Пример #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (!id.HasValue)
            {
                IsNew = true;
                Data  = new RelationsViewModel
                {
                    Data = new Relation
                    {
                        From = 0,
                        To   = 0,
                    }
                };
                return(Page());
            }
            else
            {
                IsNew = false;
                string token = await idData.GetAccessToken(HttpContext);

                if (await GetData(id.Value, token))
                {
                    return(Page());
                }
                else
                {
                    return(NotFound());
                }
            }
        }
Пример #2
0
        private async Task <bool> GetData(int id, string token)
        {
            try
            {
                Data = new RelationsViewModel {
                    Data = await client.Get(token, id)
                };
            }
            catch
            {
                return(false);
            }

            return(true);
        }