示例#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());
     }
 }
示例#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());
            }
        }
示例#3
0
 public IActionResult GetFavorites(int count)
 {
     try
     {
         using (var dal = new MonitoringDAL(""))
         {
             var linkedinProfiles = dal.LinkedinProfileDal.GetFavorites(count);
             if (linkedinProfiles is null)
             {
                 Logger.Info("GetFavoriteLinkedins is null");
                 return(NotFound());
             }
             //Logger.Info($"Messege: {JsonConvert.SerializeObject(linkedinProfiles, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
             return(Ok(JsonConvert.SerializeObject(linkedinProfiles, Formatting.Indented, new JsonSerializerSettings {
                 ReferenceLoopHandling = ReferenceLoopHandling.Ignore
             })));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
         return(BadRequest());
     }
 }
 public IActionResult GetByPage(int count, int page)
 {
     try
     {
         using (var dal = new MonitoringDAL(""))
         {
             var companies = dal.CompanyDal.GetCompanyByPage(count, page);
             if (companies is null)
             {
                 Logger.Info("GetCompaniesByPage is null");
                 return(NotFound());
             }
             //Logger.Info($"Messege: {JsonConvert.SerializeObject(companies, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
             return(Ok(JsonConvert.SerializeObject(companies, Formatting.Indented, new JsonSerializerSettings {
                 ReferenceLoopHandling = ReferenceLoopHandling.Ignore
             })));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
         return(BadRequest());
     }
 }
示例#5
0
 public IActionResult GetByUserName(string username)
 {
     try
     {
         using (var dal = new MonitoringDAL(""))
         {
             var githubProfile = dal.GithubProfileDal.GetByUserName(username);
             if (githubProfile is null)
             {
                 Logger.Info("GithubProfile is null");
                 return(NotFound());
             }
             //Logger.Info($"Messege: {JsonConvert.SerializeObject(githubProfile, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
             return(Ok(JsonConvert.SerializeObject(githubProfile, Formatting.Indented, new JsonSerializerSettings {
                 ReferenceLoopHandling = ReferenceLoopHandling.Ignore
             })));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
         return(BadRequest());
     }
 }
示例#6
0
 public IActionResult GetAll()
 {
     try
     {
         using (var dal = new MonitoringDAL(""))
         {
             var jobs = dal.JobDal.GetAllJob();
             if (jobs is null)
             {
                 Logger.Info("GetAll is null");
                 return(NotFound());
             }
             //Logger.Info($"Messege: {JsonConvert.SerializeObject(jobs, Formatting.None, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore })}");
             return(Ok(JsonConvert.SerializeObject(jobs, Formatting.Indented, new JsonSerializerSettings {
                 ReferenceLoopHandling = ReferenceLoopHandling.Ignore
             })));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e, MethodBase.GetCurrentMethod().Name);
         return(BadRequest());
     }
 }