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;
            }
        }
 public RecommendLeaderResponse(RecommendLeaderSubmissionView RecommendLeader) : this(true, ClientMessageConstant.Success, RecommendLeader)
 {
 }
        public async Task <IRecommendLeaderResponse> getRecommendLeaderDetailsAsync(int recommendId)
        {
            try
            {
                logger.Info($"{ GetType().Name}  {  ExtensionUtility.GetCurrentMethod() }  input: {recommendId} UserIPAddress: { _userIPAddress.GetUserIP().Result }");

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

                var recommendLeader = new RecommendLeadr()
                {
                    ID                   = recommendSubmission.ID,
                    FullName             = recommendSubmission.FullName,
                    RecommendingText     = recommendSubmission.RecommendingText,
                    Occupation           = recommendSubmission.Occupation,
                    ContactNumber        = recommendSubmission.ContactNumber,
                    Email                = recommendSubmission.Email,
                    LinkedinURL          = recommendSubmission.LinkedinURL,
                    TwitterURL           = recommendSubmission.TwitterURL,
                    InstagramURL         = recommendSubmission.InstagramURL,
                    RecommenderProfileID = recommendSubmission.RecommenderProfileID,
                    RecommendedProfileID = recommendSubmission.RecommendedProfileID,
                    RecommendingAudioID  = recommendSubmission.RecommendingAudioID,
                    RecommendingVideoID  = recommendSubmission.RecommendingVideoID,
                    OtherFitment         = recommendSubmission.OtherFitment,
                    SourceItemID         = recommendSubmission.SourceItemID,
                    StatusItemID         = recommendSubmission.StatusItemID,
                    Created              = recommendSubmission.Created,
                    Modified             = recommendSubmission.Modified,
                    CreatedBy            = recommendSubmission.CreatedBy,
                    ModifiedBy           = recommendSubmission.ModifiedBy
                };

                var recommendFit = await _appDbContext.RecommendationFitDetails.Where(x => x.RecommendID == recommendId).Select(x => x.RecommendationFitItemId).ToListAsync();

                List <RecommendFitListView> fitmentList = new List <RecommendFitListView>();
                foreach (var item in recommendFit)
                {
                    if (item != null)
                    {
                        var RecommendFitList = await _appDbContext.LookupItems.Where(k => k.Id == item).OrderBy(k => k.NameEn).FirstOrDefaultAsync();

                        RecommendFitListView fitList = new RecommendFitListView()
                        {
                            ID     = RecommendFitList.Id,
                            NameEn = RecommendFitList.NameEn,
                            NameAr = RecommendFitList.NameAr
                        };
                        fitmentList.Add(fitList);
                    }
                }

                var data = new RecommendLeaderSubmissionView()
                {
                    RecommendLeaderSubmission     = _mapper.Map <RecommendSubmissionView>(recommendLeader),
                    RecommendLeaderFitmentDetails = fitmentList,
                };
                var profile = await _appDbContext.Profiles.FirstOrDefaultAsync(k => k.Id == recommendSubmission.RecommenderProfileID);

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

                var user = await _appDbContext.Users.FirstOrDefaultAsync(k => k.Id == recommendSubmission.RecommenderProfileID);

                if (profile != null)
                {
                    data.RecommendLeaderSubmission.RecommendedBy = 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 = user?.OriginalImageFileId ?? 0
                    };
                }

                return(new RecommendLeaderResponse(data));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw ex;
            }
        }
 private RecommendLeaderResponse(bool success, string message, RecommendLeaderSubmissionView recommendLeaderSubmission) : base(success, message)
 {
     RecommendLeaderSubmission = recommendLeaderSubmission;
 }