Пример #1
0
        public async Task <IActionResult> GetSurroundingBlocksByBlock(string blockId, string countryId)
        {
            //TODO: your code here
            try
            {
                if (string.IsNullOrEmpty(blockId) || string.IsNullOrEmpty(countryId))
                {
                    return(Json(new { IsSuccess = false, Message = "Invalid request parameters." }));
                }

                if (!await _residenceService.GetIsResidentOfCountry(_userAppContext.CurrentUserId, countryId))
                {
                    return(Json(new { IsSuccess = false, Message = "The current user is not the resident of the country." }));
                }

                else
                {
                    var blocks = await _blockService.GetSurroundingBlocksByBlockId(blockId);

                    return(Json(new { IsSuccess = true, Blocks = blocks }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { IsSuccess = false, Message = e.Message }));
            }
        }