コード例 #1
0
        public async Task <JsonResult> Get(string req)
        {
            var result = new CompanyResponse {
                Success = false,
                Error   = null,
                Data    = null
            };

            if (!Guid.TryParse(req, out Guid guid))
            {
                result.Error = "Guid not provided";
            }
            else
            {
                var company = await _hostRepo.GetCompanyByGuid(guid);

                if (company == null)
                {
                    result.Error = "Company not found";
                }
                else
                {
                    var statistics = await _statsRepo.GetStatisticsByCompanyId(company.CompanyId);

                    result.Data    = Map(company, statistics, guid);
                    result.Success = true;
                }
            }
            return(new JsonResult(result, JsonSerializerSettings));
        }