コード例 #1
0
 public async Task<ActionResult<V1DTO.ProfileDTO>> GetUserProfileData(Guid userId)
 {
     var profile = await _bll.Profiles.GetByUserAsync(userId, User.UserGuidId());
     if (profile == null)
     {
         return NotFound(new V1DTO.MessageDTO($"Profile for user {userId} not found"));
     }
     // Only friends can see profile if it's set as private
     var isRequestingUserFriend = _bll.Friendships.GetForUserConfirmedAsync(userId, User.UserGuidId()) != null;
     if (profile.IsPrivate && !isRequestingUserFriend)
     {
         return NotFound(new V1DTO.MessageDTO($"Profile for user {userId} not found"));
     }
     return Ok(_mapper.Map(profile));
 }
コード例 #2
0
        public ActionResult Friends()
        {
            var user     = userService.GetUserByEmail(HttpContext.User.Identity.Name);
            var requests = profileService.GetAllRequests(user.Id);

            return(View(ProfileMapper.Map(requests)));
        }
コード例 #3
0
        /// <summary>
        /// The method for profile searching
        /// </summary>
        /// <param name="stringKey"></param>
        /// <param name="city"></param>
        /// <returns></returns>
        public IEnumerable <BllProfile> Find(string stringKey = "", string city = null)
        {
            var profiles = uow.Profiles.GetAll();

            if (!ReferenceEquals(stringKey, null))
            {
                profiles = profiles.Where(p => (p.FirstName + " " + p.LastName).Contains(stringKey));
            }
            if (!ReferenceEquals(city, null))
            {
                profiles = profiles.Where(p => p.City != null && p.City.Contains(city));
            }

            return(ProfileMapper.Map(profiles));
        }
コード例 #4
0
        public ActionResult Index(SearchModel model, int page = 1)
        {
            var bllProfiles = profiles.Find(model.StringKey, model.City);
            var result      = ProfileMapper.Map(bllProfiles);

            model.Profiles = new GenericPaginationModel <ProfileModel>(page, 5, result.ToList());
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Search", model));
            }
            else
            {
                return(View(model));
            }
        }
コード例 #5
0
        public Profile View(string profile)
        {
            DataSet   dataSet = this.repository.View(profile);
            DataTable table   = dataSet.Tables[0];
            Dictionary <String, String> data = new Dictionary <string, string>();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                //table.Rows[i][0] RESOURCE_NAME
                //table.Rows[i][1] LIMIT
                data.Add(table.Rows[i][0].ToString(), table.Rows[i][1].ToString());
            }
            Profile result = ProfileMapper.Map(data);

            result.Name = profile;

            return(result);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: tralivali1234/opentk-1
        /// <summary>
        /// Asynchronously generates bindings for the API described by the given <see cref="IGeneratorSettings"/>
        /// object.
        ///
        /// Broadly, this takes the following steps:
        /// 1) Load the base API.
        /// 2) Bake overrides into the API
        /// 3) Bake Documentation into the API
        /// 4) Create mappings between OpenGL types and C# types
        /// 5) Apply the mappings to the API
        /// 6) Bake convenience overloads into the API (adding unsafe, etc)
        /// 7) Write the bindings to the files.
        ///
        /// </summary>
        /// <param name="generatorSettings">The settings describing the API.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        private static async Task GenerateBindingsAsync([NotNull] IGeneratorSettings generatorSettings)
        {
            var signaturePath = Path.Combine(Arguments.InputPath, generatorSettings.SpecificationFile);

            if (!_cachedProfiles.TryGetValue(signaturePath, out var profiles))
            {
                profiles = SignatureReader.GetAvailableProfiles(signaturePath).ToList();
                _cachedProfiles.TryAdd(signaturePath, profiles);
            }

            var profileOverrides = OverrideReader
                                   .GetProfileOverrides(generatorSettings.OverrideFiles.ToArray())
                                   .ToList();

            var baker        = new ProfileBaker(profiles, profileOverrides);
            var bakedProfile = baker.BakeProfile
                               (
                generatorSettings.ProfileName,
                generatorSettings.Versions,
                generatorSettings.BaseProfileName
                               );

            var documentationPath = Path.Combine
                                    (
                Arguments.DocumentationPath,
                generatorSettings.SpecificationDocumentationPath
                                    );

            var docs      = DocumentationReader.ReadProfileDocumentation(documentationPath);
            var bakedDocs = new DocumentationBaker(bakedProfile).BakeDocumentation(docs);

            var languageTypemapPath = Path.Combine(Arguments.InputPath, generatorSettings.LanguageTypemap);

            if (!_cachedTypemaps.TryGetValue(languageTypemapPath, out var languageTypemap))
            {
                using (var fs = File.OpenRead(languageTypemapPath))
                {
                    languageTypemap = new TypemapReader().ReadTypemap(fs);
                    _cachedTypemaps.TryAdd(languageTypemapPath, languageTypemap);
                }
            }

            var apiTypemapPath = Path.Combine(Arguments.InputPath, generatorSettings.APITypemap);

            if (!_cachedTypemaps.TryGetValue(apiTypemapPath, out var apiTypemap))
            {
                using (var fs = File.OpenRead(apiTypemapPath))
                {
                    apiTypemap = new TypemapReader().ReadTypemap(fs);
                    _cachedTypemaps.TryAdd(apiTypemapPath, apiTypemap);
                }
            }

            var bakedMap = TypemapBaker.BakeTypemaps(apiTypemap, languageTypemap);

            var mapper        = new ProfileMapper(bakedMap);
            var mappedProfile = mapper.Map(bakedProfile);

            var overloadedProfile = OverloadBaker.BakeOverloads(mappedProfile);

            var bindingsWriter = new BindingWriter(generatorSettings, overloadedProfile, bakedDocs);
            await bindingsWriter.WriteBindingsAsync();
        }