Beispiel #1
0
 public IActionResult GetAllCrossProfiles()
 {
     try
     {
         var crossProfileModels = new List <ProfileCrossModel>();
         using (var dal = new MonitoringDAL(""))
         {
             var crossProfiles = dal.CrossProfileDal.GetAllCrossProfiles();
             foreach (var crossProfile in crossProfiles)
             {
                 var crossProfileModel = new ProfileCrossModel
                 {
                     LinkedinProfile = dal.LinkedinProfileDal.GetById(crossProfile.LinkedinUserId),
                     GithubProfile   = dal.GithubProfileDal.GetById(crossProfile.GithubUserId)
                 };
                 crossProfileModels.Add(crossProfileModel);
             }
         }
         Logger.Info($"Messege: {JsonConvert.SerializeObject(crossProfileModels, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
         return(Ok(JsonConvert.SerializeObject(crossProfileModels, Formatting.Indented, new JsonSerializerSettings {
             ReferenceLoopHandling = ReferenceLoopHandling.Ignore
         })));
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
         return(BadRequest());
     }
 }
Beispiel #2
0
        public IActionResult GetCrossProfileByUsername([FromBody] CrossProfileSearchModel searchModel)
        {
            ProfileCrossModel crossProfileModel;

            try
            {
                using (MonitoringDAL dal = new MonitoringDAL(string.Empty))
                {
                    switch (searchModel.ContentType)
                    {
                    case ContentType.Github:
                    {
                        var githubProfileId = dal.GithubProfileDal.GetByUserName(searchModel.Username).Id;
                        var crossProfile    = dal.CrossProfileDal.GetCrossProfileByGithubProfileId(githubProfileId);
                        crossProfileModel = new ProfileCrossModel
                        {
                            LinkedinProfile = dal.LinkedinProfileDal.GetById(crossProfile.LinkedinUserId),
                            GithubProfile   = dal.GithubProfileDal.GetById(crossProfile.GithubUserId)
                        };
                    }
                    break;

                    case ContentType.Linkedin:
                    {
                        var linkedinProfileId = dal.GithubProfileDal.GetByUserName(searchModel.Username).Id;
                        var crossProfile      = dal.CrossProfileDal.GetCrossProfileByGithubProfileId(linkedinProfileId);
                        crossProfileModel = new ProfileCrossModel
                        {
                            LinkedinProfile = dal.LinkedinProfileDal.GetById(crossProfile.LinkedinUserId),
                            GithubProfile   = dal.GithubProfileDal.GetById(crossProfile.GithubUserId)
                        };
                    }
                    break;

                    default:
                        crossProfileModel = null;
                        break;
                    }
                }
                Logger.Info($"Messege: {JsonConvert.SerializeObject(crossProfileModel, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
                return(Ok(JsonConvert.SerializeObject(crossProfileModel, Formatting.Indented, new JsonSerializerSettings {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                })));
            }
            catch (Exception e)
            {
                Logger.Error(e, MethodBase.GetCurrentMethod().Name);
                return(BadRequest());
            }
        }