コード例 #1
0
        private async Task <int?> FileUploadAsync(IFormFile formFile, Profile profile, List <FileView> allResponse, DocumentType type)
        {
            try
            {
                var savedEntity = await SaveFileAsync(formFile, profile.Id);

                allResponse.Add(GetResponse(savedEntity.Id, type, formFile));
                await UploadIntoFileDbAsync(savedEntity.IdGuid, formFile);

                return(savedEntity.Id);
            }
            catch (Exception e)
            {
                allResponse.Add(new FileView
                {
                    DocumentType    = type,
                    IsSuccess       = false,
                    ResponseMessage = ClientMessageConstant.WeAreUnableToProcessYourRequest
                });
            }

            return(null);
        }
コード例 #2
0
        public async Task <IRecommendLeaderResponse> AddRecommendLeader(RecommendLeaderView view)
        {
            try
            {
                logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  input: {view.ToJsonString()} UserIPAddress: { _userIPAddress.GetUserIP().Result }");


                var firstName = await _appDbContext.Profiles.Where(k => k.Id == view.ProfileID).Select(k => k.FirstNameEn).FirstOrDefaultAsync();

                var lastName = await _appDbContext.Profiles.Where(k => k.Id == view.ProfileID).Select(k => k.LastNameEn).FirstOrDefaultAsync();

                var userName = firstName + " " + lastName;

                var matchingProfileId = 0;
                var profileUrl        = "";

                var RecommendStatusItem = await _appDbContext.LookupItems.Where(k => k.LookupId == (int)LookupType.StatusItem).OrderBy(k => k.NameEn).FirstOrDefaultAsync();

                //var email = await _appDbContext.UserInfos.Where(k => k.UserId == view.ProfileID).Select(k => k.Email).FirstOrDefaultAsync();
                var linkedinUrl = new Profile();
                var TwitterUrl  = new Profile();
                var email       = new UserInfo();
                var mobile      = new UserInfo();
                if (view.LinkedinURL != null)
                {
                    linkedinUrl = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == view.LinkedinURL).FirstOrDefaultAsync();
                }
                if (view.TwitterURL != null)
                {
                    TwitterUrl = await _appDbContext.Profiles.Where(x => x.TwitterUrl == view.TwitterURL).FirstOrDefaultAsync();
                }

                if (view.Email != null)
                {
                    email = await _appDbContext.UserInfos.Where(x => x.Email == view.Email).FirstOrDefaultAsync();
                }

                if (view.ContactNumber != null)
                {
                    mobile = await _appDbContext.UserInfos.Where(x => x.Mobile == view.ContactNumber).FirstOrDefaultAsync();
                }

                if (linkedinUrl?.LinkedInUrl != null || TwitterUrl?.TwitterUrl != null || email?.Email != null || mobile?.Mobile != null)
                {
                    profileUrl        = "https://stagingplatform.uaeglp.gov.ae/";
                    matchingProfileId = email.Email != null ? email.Id
                                        : mobile.Mobile != null ? mobile.Id
                                        : linkedinUrl.LinkedInUrl != null ? linkedinUrl.Id
                                        : TwitterUrl.TwitterUrl != null ? TwitterUrl.Id : 0;
                }

                var recommendLeader = new RecommendLeadr()
                {
                    FullName             = view.FullName,
                    RecommendingText     = view.RecommendingText,
                    Occupation           = view.Occupation,
                    ContactNumber        = view.ContactNumber,
                    Email                = view.Email,
                    LinkedinURL          = view.LinkedinURL,
                    TwitterURL           = view.TwitterURL,
                    InstagramURL         = view.InstagramURL,
                    RecommenderProfileID = view.ProfileID != 0 ? view.ProfileID : null,
                    OtherFitment         = view.OthersText,
                    SourceItemID         = view.SourceItemID,
                    StatusItemID         = RecommendStatusItem.Id,
                    Created              = DateTime.Now,
                    Modified             = DateTime.Now,
                    CreatedBy            = view.ProfileID != null ? userName : "******",
                    ModifiedBy           = view.ProfileID != null ? userName : "******",
                    RecommendedProfileID = matchingProfileId != 0 ? matchingProfileId : (int?)null
                };

                if (view.AudioFile != null)
                {
                    var audioGuid = Guid.NewGuid();
                    recommendLeader.RecommendingAudioID = audioGuid;
                    minioAudioVideoUpload(view.AudioFile, "audio", audioGuid);
                }

                if (view.VideoFile != null)
                {
                    var videoGuid = Guid.NewGuid();
                    recommendLeader.RecommendingVideoID = videoGuid;
                    minioAudioVideoUpload(view.VideoFile, "video", videoGuid);
                }

                await _appDbContext.RecommandLeaders.AddAsync(recommendLeader);

                await _appDbContext.SaveChangesAsync();

                var recommendId = await _appDbContext.RecommandLeaders.Where(x => x.ID == recommendLeader.ID).Select(x => x.ID).FirstOrDefaultAsync();

                List <int?> FitList = new List <int?>();

                FitList = view.RecommendLeaderFit != null ? view.RecommendLeaderFit : null;

                var recommendFit      = new RecommendationFitDetails();
                var recommendFitOther = new RecommandationOther();
                if (FitList != null)
                {
                    foreach (var item in FitList)
                    {
                        recommendFit = new RecommendationFitDetails()
                        {
                            RecommendID             = recommendId,
                            RecommendationFitItemId = item
                        };

                        await _appDbContext.RecommendationFitDetails.AddAsync(recommendFit);

                        await _appDbContext.SaveChangesAsync();

                        _appDbContext.Entry(recommendFit).State = EntityState.Detached;
                    }
                }

                var data = new RecommendLeaderSubmissionView()
                {
                    RecommendLeaderSubmission = _mapper.Map <RecommendSubmissionView> (recommendLeader),
                    RecommendLeaderFitment    = FitList,
                };

                data.RecommendLeaderSubmission.RecommendViewProfileURL = profileUrl;
                return(new RecommendLeaderResponse(data));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }
コード例 #3
0
        public async Task <List <RecommendSubmissionView> > GetAllRecommendLeaderListAsync(int skip, int limit)
        {
            try
            {
                logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() } UserIPAddress: { _userIPAddress.GetUserIP().Result }");

                var recommendSubmission = await _appDbContext.RecommandLeaders.OrderByDescending(x => x.Created).Skip(skip).Take(limit).ToListAsync();

                //var profileIds = recommendSubmission
                ///var  profileUrl = "";
                //int profileId = 0;
                var linkedinUrl = new Profile();
                var TwitterUrl  = new Profile();
                var email       = new UserInfo();
                var mobile      = new UserInfo();

                var recommendLeaderList = _mapper.Map <List <RecommendSubmissionView> >(recommendSubmission);

                foreach (var item in recommendLeaderList)
                {
                    var profileUrl = "";
                    var stagingUrl = "https://stagingplatform.uaeglp.gov.ae/";
                    //int profileId = 0;
                    var recommendUser = await _appDbContext.RecommandLeaders.Where(x => x.ID == item.ID).FirstOrDefaultAsync();

                    if (recommendUser.LinkedinURL != null)
                    {
                        linkedinUrl = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == recommendUser.LinkedinURL).FirstOrDefaultAsync();
                    }
                    if (recommendUser.TwitterURL != null)
                    {
                        TwitterUrl = await _appDbContext.Profiles.Where(x => x.TwitterUrl == recommendUser.TwitterURL).FirstOrDefaultAsync();
                    }

                    if (recommendUser.Email != null)
                    {
                        email = await _appDbContext.UserInfos.Where(x => x.Email == recommendUser.Email).FirstOrDefaultAsync();
                    }

                    if (recommendUser.ContactNumber != null)
                    {
                        mobile = await _appDbContext.UserInfos.Where(x => x.Mobile == recommendUser.ContactNumber).FirstOrDefaultAsync();
                    }

                    if ((recommendUser.LinkedinURL != null && linkedinUrl?.LinkedInUrl != null) || (recommendUser.TwitterURL != null && TwitterUrl?.TwitterUrl != null) || (recommendUser.Email != null && email?.Email != null) || (recommendUser.ContactNumber != null && mobile?.Mobile != null))
                    {
                        profileUrl = email.Email != null ? stagingUrl
                                                    : mobile.Mobile != null ? stagingUrl
                                                    : linkedinUrl.LinkedInUrl != null ? stagingUrl
                                                    : TwitterUrl.TwitterUrl != null ? stagingUrl : "";
                    }
                    item.RecommendViewProfileURL = profileUrl;
                    item.RecommendViewProfileID  = recommendUser.RecommendedProfileID;
                }

                return(recommendLeaderList);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }
コード例 #4
0
        public async Task <RecommendProfileView> GetViewMatchProfile(int recommendId)
        {
            try
            {
                logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  input: {recommendId} UserIPAddress: { _userIPAddress.GetUserIP().Result }");

                var profileUrl = "";

                var profileRecommended = await _appDbContext.RecommandLeaders.Where(x => x.RecommendedProfileID == 0 || x.RecommendedProfileID == null).ToListAsync();

                foreach (var item in profileRecommended)
                {
                    var linkedinUrl = new Profile();
                    var TwitterUrl  = new Profile();
                    var email       = new UserInfo();
                    var mobile      = new UserInfo();
                    if (item.LinkedinURL != null)
                    {
                        linkedinUrl = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == item.LinkedinURL).FirstOrDefaultAsync();
                    }
                    if (item.TwitterURL != null)
                    {
                        TwitterUrl = await _appDbContext.Profiles.Where(x => x.TwitterUrl == item.TwitterURL).FirstOrDefaultAsync();
                    }

                    if (item.Email != null)
                    {
                        email = await _appDbContext.UserInfos.Where(x => x.Email == item.Email).FirstOrDefaultAsync();
                    }

                    if (item.TwitterURL != null)
                    {
                        mobile = await _appDbContext.UserInfos.Where(x => x.Mobile == item.ContactNumber).FirstOrDefaultAsync();
                    }

                    if ((item.LinkedinURL != null && linkedinUrl?.LinkedInUrl != null) || (item.TwitterURL != null && TwitterUrl?.TwitterUrl != null) || (item.Email != null && email?.Email != null) || (item.ContactNumber != null && mobile?.Mobile != null))
                    {
                        item.RecommendedProfileID = email.Email != null ? email.Id
                                                    : mobile.Mobile != null ? mobile.Id
                                                    : linkedinUrl.LinkedInUrl != null ? linkedinUrl.Id
                                                    : TwitterUrl.TwitterUrl != null ? TwitterUrl.Id : 0;

                        await _appDbContext.SaveChangesAsync();
                    }
                }

                var data = new RecommendProfileView();

                var recommendUser = await _appDbContext.RecommandLeaders.Where(x => x.ID == recommendId).FirstOrDefaultAsync();

                var linkedinUrlVal = new Profile();
                var TwitterUrlVal  = new Profile();
                var emailVal       = new UserInfo();
                var mobileVal      = new UserInfo();

                if (recommendUser.LinkedinURL != null)
                {
                    linkedinUrlVal = await _appDbContext.Profiles.Where(x => x.LinkedInUrl == recommendUser.LinkedinURL).FirstOrDefaultAsync();
                }
                if (recommendUser.TwitterURL != null)
                {
                    TwitterUrlVal = await _appDbContext.Profiles.Where(x => x.TwitterUrl == recommendUser.TwitterURL).FirstOrDefaultAsync();
                }

                if (recommendUser.Email != null)
                {
                    emailVal = await _appDbContext.UserInfos.Where(x => x.Email == recommendUser.Email).FirstOrDefaultAsync();
                }

                if (recommendUser.ContactNumber != null)
                {
                    mobileVal = await _appDbContext.UserInfos.Where(x => x.Mobile == recommendUser.ContactNumber).FirstOrDefaultAsync();
                }

                if (linkedinUrlVal?.LinkedInUrl != null || TwitterUrlVal?.TwitterUrl != null || emailVal?.Email != null || mobileVal?.Mobile != null)
                {
                    profileUrl = "https://stagingplatform.uaeglp.gov.ae/";
                }

                var fullname = recommendUser.FullName != null?recommendUser.FullName.Trim().Split(new char[0]) : null;

                List <Profile> matchProfiles = new List <Profile>();
                if (fullname != null)
                {
                    if (fullname.Length == 1)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[0])).ToListAsync();
                    }
                    else if (fullname.Length == 2)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1])).ToListAsync();
                    }
                    else if (fullname.Length == 3)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) || x.FirstNameEn.StartsWith(fullname[2]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1]) || x.LastNameEn.StartsWith(fullname[2])).ToListAsync();
                    }
                    else if (fullname.Length == 4)
                    {
                        matchProfiles = await _appDbContext.Profiles.Where(x => x.FirstNameEn.StartsWith(fullname[0]) || x.FirstNameEn.StartsWith(fullname[1]) || x.FirstNameEn.StartsWith(fullname[2]) || x.FirstNameEn.StartsWith(fullname[3]) ||
                                                                           x.LastNameEn.StartsWith(fullname[0]) || x.LastNameEn.StartsWith(fullname[1]) || x.LastNameEn.StartsWith(fullname[2]) || x.LastNameEn.StartsWith(fullname[3])).ToListAsync();
                    }
                }
                //var matchProfile = await _appDbContext.Profiles.Where(x => recommendUser.FullName.Contains(x.FirstNameEn) ||
                //recommendUser.FullName.Contains(x.LastNameEn)).ToListAsync();
                //var matchProfile = await _appDbContext.Profiles.FromSqlRaw($"SELECT * FROM dbo.Profile where soundex(firstNameEn) = soundex('{recommendUser.FullName}')").ToListAsync();
                //var matchProfile = await _appDbContext.Profiles.FromSqlRaw($"select  * from dbo.Profile where difference(soundex(FirstNameEN + ' ' + LastNameEN),soundex('{recommendUser.FullName}')) = 4").ToListAsync();

                List <PublicProfileView> matchProfileDetails = new List <PublicProfileView>();
                foreach (var item in matchProfiles)
                {
                    var profile = await _appDbContext.Profiles.FirstOrDefaultAsync(k => k.Id == item.Id);

                    var workExperience = await _appDbContext.ProfileWorkExperiences.Include(k => k.Title)
                                         .Where(k => k.ProfileId == item.Id).OrderByDescending(y => y.DateFrom).FirstOrDefaultAsync();

                    var userDetails = await _appDbContext.Users.FirstOrDefaultAsync(k => k.Id == item.Id);

                    PublicProfileView user = new PublicProfileView()
                    {
                        Id              = profile.Id,
                        FirstNameAr     = profile.FirstNameAr,
                        FirstNameEn     = profile.FirstNameEn,
                        LastNameAr      = profile.LastNameAr,
                        LastNameEn      = profile.LastNameEn,
                        SecondNameAr    = profile.SecondNameAr,
                        SecondNameEn    = profile.SecondNameEn,
                        ThirdNameAr     = profile.ThirdNameAr,
                        ThirdNameEn     = profile.ThirdNameEn,
                        Designation     = workExperience?.Title?.TitleEn,
                        DesignationAr   = workExperience?.Title?.TitleAr,
                        UserImageFileId = userDetails.OriginalImageFileId ?? 0
                    };

                    matchProfileDetails.Add(user);
                }

                if (matchProfiles != null)
                {
                    data = new RecommendProfileView()
                    {
                        RecommendMatchProfileList = matchProfileDetails,
                        RecommendViewProfileURL   = profileUrl
                    };
                }

                return(data);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }