示例#1
0
        public async Task <IActionResult> GetById(Guid profileId, Guid employeeId)
        {
            var profileResult = await _profileReadCommand.ExecuteAsync(profileId);

            var employeeResult = await _employeeReadCommand.ExecuteAsync(employeeId);

            var userInfo = new UserInfoResult
            {
                Profile        = profileResult,
                ShortName      = employeeResult.Organization?.ShortName,
                AcademicDegree = employeeResult.AcademicDegree,
                AcademicRank   = employeeResult.AcademicRank,
                Education      = employeeResult.Education,
                Fio            = employeeResult.Passport?.ToFio(),
                Email          = employeeResult.Contact?.Email,
                /// TODO: реализовать получение и заполнение факсов + база
                Fax = null,
                MobilePhoneNumber = employeeResult.Contact?.MobilePhoneNumber,
                WorkPlace         = employeeResult.WorkPlace,
                Position          = employeeResult.Position
            };

            var objectJson = JsonSerializer.SerializeToUtf8Bytes(userInfo, new JsonSerializerOptions
            {
                WriteIndented        = true,
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            });

            var mediaType = new MediaTypeHeaderValue("application/octet-stream");
            var result    = new FileContentResult(objectJson, mediaType);

            return(result);
        }
示例#2
0
        public async Task <IActionResult> GetById(Guid profileId, Guid employeeId)
        {
            var profileResult = await _profileReadCommand.ExecuteAsync(profileId);

            var employeeResult = await _employeeReadCommand.ExecuteAsync(employeeId);

            var userInfo = new UserInfoResult
            {
                Profile        = profileResult,
                ShortName      = employeeResult.Organization?.ShortName,
                AcademicDegree = employeeResult.AcademicDegree,
                AcademicRank   = employeeResult.AcademicRank,
                Education      = employeeResult.Education,
                Fio            = employeeResult.Passport?.ToFio(),
                Email          = employeeResult.Contact?.Email,
                ///TODO: реализовать получение и заполнение факсов + база
                Fax = null,
                MobilePhoneNumber = employeeResult.Contact?.MobilePhoneNumber,
                WorkPlace         = employeeResult.WorkPlace,
                Position          = employeeResult.Position
            };

            var jsonOptions = new JsonSerializerOptions()
            {
                WriteIndented        = true,
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };

            var objectJson = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(userInfo, jsonOptions);

            /*var objectJson = JsonConvert.SerializeObject(userInfo, new JsonSerializerSettings
             * {
             *  ContractResolver = new DefaultContractResolver
             *  {
             *      NamingStrategy = new CamelCaseNamingStrategy()
             *  },
             *  Formatting = Formatting.Indented
             * });*/

            /*var result = new HttpResponseMessage(HttpStatusCode.OK)
             * {
             *  Content = new StringContent(objectJson)
             * };
             *
             * result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");*/

            var mediaType = new Microsoft.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
            var result    = new FileContentResult(objectJson, mediaType);

            return(result);
        }
        public Task <EmployeeResult> GetAsync(Guid employeeId)
        {
            Contract.Argument.IsNotEmptyGuid(employeeId, nameof(employeeId));

            return(_employeeReadCommand.ExecuteAsync(employeeId));
        }