Пример #1
0
        private async Task <string[]> AddToGlobalStrings(string input)
        {
            var words = RemoveStopwords(input).Split();

            words = StemmWords(words);

            var wds = RemoveStopwords(input).Split();

            wds = StemmWords(wds);

            for (int i = 0; i < words.Length; i++)
            {
                var result = await _context.GlobalStrings.Where(x => x.Word == words[i]).CountAsync();

                if (result == 0)
                {
                    var globalString = new GlobalString();
                    globalString.Word = words[i];
                    await _context.GlobalStrings.AddAsync(globalString);
                }
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw e;
            }

            return(wds);
        }
Пример #2
0
        public EducationalInformationVm GetEducationInformation(long id, UserInfo user)
        {
            List <IndividualEducationlevel> ds;

            using (var db = new LMISEntities())
            {
                ds = db.IndividualEducationlevels
                     .Where(r => r.IsDeleted == null && r.PortalUsersID == user.PortalUserId && r.IndividualEducationlevelID == id)
                     .ToList();
                GlobalString nullname = new GlobalString("", "", "");
                //  nullname. = null;
                return(ds.Select(r => new EducationalInformationVm()
                {
                    IndividualEducationlevelID = (long)r.IndividualEducationlevelID,
                    Degree = (!string.IsNullOrWhiteSpace(r.Degree)) ? r.Degree.Trim() : null,
                    Name = r.IndividualEducationlevelDets.Select(d => new LocalString(d.LanguageID, d.InstitutionName)).ToList(),
                    EducationalLevelId = r.LevelOfEducation,
                    Grade = r.IndividualEducationlevelDets.Select(d => new LocalString(d.LanguageID, d.Grade)).ToList(),
                    graduationyear = r.GraduationYear,
                    Percentage = (r.GradePrecentage.HasValue) ? r.GradePrecentage.Value : 0,
                    InstitutionType = r.IndividualEducationlevelDets.Select(d => new LocalString(d.LanguageID, d.InstitutionType)).ToList(),
                    CertificationType = r.IndividualEducationlevelDets.Select(d => new LocalString(d.LanguageID, d.CertificationType)).ToList(),
                    FacultyName = r.IndividualEducationlevelDets.Select(d => new LocalString(d.LanguageID, d.FacultyName)).ToList(),
                    GradeGPA = (r.GradeGPA.HasValue) ? (float)r.GradeGPA.Value : 0
                })
                       .SingleOrDefault());
            }
        }
Пример #3
0
 private void GetEmojiForPlayerId(GlobalString playerId, GlobalString emojiForPlayerId)
 {
     if (playerId.Value != null)
     {
         ICollection <string> emojiCollection;
         if (currentPlayingState.PlayerEmojis.TryGetValue(playerId.Value, out emojiCollection) && emojiCollection.Count > 0)
         {
             foreach (var emoji in emojiCollection)
             {
                 emojiForPlayerId.Value = emoji;
                 break;
             }
         }
     }
 }
Пример #4
0
        public void UpdateProfile(ref OrgVm vm, string userId)
        {
            using (var db = new LMISEntities())
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var portalUserId   = vm.PortalUserId;
                        var isSelfEmployed = vm.OrgType == "10000003";
                        var isIndustrial   = vm.Activity == "03200004";
                        var otherIndustry  = vm.OtherIndustry;
                        var telephoneNo    = vm.ContactInfo.Telephone;

                        if (string.IsNullOrWhiteSpace(vm.Industry))
                        {
                            vm.Industry = "";
                        }
                        else if (vm.Industry.Length != 8)
                        {
                            vm.Industry = "";
                        }
                        if (!isIndustrial || vm.Industry.Length == 8)
                        {
                            otherIndustry = new GlobalString();
                        }
                        if (telephoneNo == null)
                        {
                            telephoneNo = "";
                        }

                        var portalUser = db.PortalUsers.Single(r => r.PortalUsersID == portalUserId);

                        portalUser.IDType           = vm.IDType;
                        portalUser.IDNumber         = vm.ID;
                        portalUser.UserSubCategory  = vm.OrgType;
                        portalUser.TrainingSeeker   = vm.ReceiveTraining;
                        portalUser.TrainingProvider = vm.OfferTraining;
                        portalUser.Employer         = vm.OfferJobs;

                        var org = db.OrganizationDetails.Single(r => r.PortalUsersID == portalUserId);

                        org.OrganizationLogoPath    = string.IsNullOrWhiteSpace(vm.LogoFileName) ? "" : vm.LogoFileName;
                        org.OrganizationProfilePath = vm.ProfileFileName;
                        org.OrganizationSize        = vm.OrgSize;
                        org.CountryID                 = vm.ContactInfo.Country;
                        org.CityID                    = vm.ContactInfo.City;
                        org.ZipPostalCode             = vm.ContactInfo.PostalCode;
                        org.Telephone                 = telephoneNo;
                        org.OrganizationWebsite       = vm.ContactInfo.Website;
                        org.EconomicActivity          = vm.Activity;
                        org.IndustryType              = isIndustrial ? vm.Industry : null;
                        org.EstablishmentDate         = vm.DateEstablished;
                        org.YearsofExperienceID       = isSelfEmployed ? vm.YOE : "";
                        org.RegistrationNumberWithITC = vm.OfferTraining ? vm.ItcRegNo : null;
                        org.Is_Approved               = (byte)vm.Approval;
                        org.UpdateDate                = DateTime.UtcNow;
                        org.UpdateUserID              = userId;

                        db.OrganizationDetails_Det.RemoveRange(org.OrganizationDetails_Det);

                        var orgDets = Utils.MultilingualDataSet(
                            new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.OrgName },
                            { "c2", vm.ContactInfo.Address },
                            { "c3", otherIndustry }
                        });

                        foreach (var r in orgDets)
                        {
                            org.OrganizationDetails_Det.Add(new OrganizationDetails_Det()
                            {
                                LanguageID        = r["c1"].L,
                                OrganizationName  = r["c1"].T,
                                Address           = r["c2"].T,
                                OtherIndustryType = r["c3"].T
                            });
                        }

                        var orgAdmin = org.OrganizationContact_Info.Single(r =>
                                                                           r.PortalUsersID == portalUserId && r.UserID == userId &&
                                                                           r.JobTitleID.Trim().ToLower() == "admin");

                        orgAdmin.Telephone    = telephoneNo;
                        orgAdmin.UpdateDate   = DateTime.UtcNow;
                        orgAdmin.UpdateUSerID = userId;

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }
        }
Пример #5
0
        public long SignUp(ref OrgVm vm)
        {
            using (var db = new LMISEntities())
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var userName       = vm.UserName;
                        var userId         = db.AspNetUsers.Where(u => u.UserName == userName).Select(u => u.Id).Single();
                        var isSelfEmployed = vm.OrgType == "10000003";
                        var isIndustrial   = vm.Activity == "03200004";
                        var otherIndustry  = vm.OtherIndustry;
                        var telephoneNo    = vm.ContactInfo.Telephone;

                        if (string.IsNullOrWhiteSpace(vm.Industry))
                        {
                            vm.Industry = "";
                        }
                        else if (vm.Industry.Length != 8)
                        {
                            vm.Industry = "";
                        }
                        if (!isIndustrial || vm.Industry.Length == 8)
                        {
                            otherIndustry = new GlobalString();
                        }
                        if (telephoneNo == null)
                        {
                            telephoneNo = "";
                        }

                        var portalUser = db.PortalUsers.Add(new PortalUser()
                        {
                            IDType           = vm.IDType,
                            IDNumber         = vm.ID,
                            UserCategory     = "ORG",
                            UserSubCategory  = vm.OrgType,
                            TrainingSeeker   = vm.ReceiveTraining,
                            TrainingProvider = vm.OfferTraining,
                            Employer         = vm.OfferJobs,
                            JobSeeker        = false,
                            Researcher       = true,
                            Internal         = false,
                            IsSubscriper     = false
                        });

                        db.SaveChanges();
                        var portalUserId = portalUser.PortalUsersID;
                        vm.PortalUserId = (long)portalUserId;

                        var org = db.OrganizationDetails.Add(new OrganizationDetail()
                        {
                            PortalUsersID           = portalUserId,
                            OrganizationLogoPath    = string.IsNullOrWhiteSpace(vm.LogoFileName) ? "" : vm.LogoFileName,
                            OrganizationProfilePath = vm.ProfileFileName,
                            OrganizationSize        = vm.OrgSize,
                            CountryID                 = vm.ContactInfo.Country,
                            CityID                    = vm.ContactInfo.City,
                            ZipPostalCode             = vm.ContactInfo.PostalCode,
                            Telephone                 = telephoneNo,
                            OrganizationWebsite       = vm.ContactInfo.Website,
                            EconomicActivity          = vm.Activity,
                            IndustryType              = isIndustrial ? vm.Industry : null,
                            EstablishmentDate         = vm.DateEstablished,
                            YearsofExperienceID       = isSelfEmployed ? vm.YOE : "",
                            RegistrationNumberWithITC = vm.OfferTraining ? vm.ItcRegNo : null,
                            IsDiscalaimerApproved     = true,
                            Is_Approved               = (byte)vm.Approval,
                            PostDate                  = DateTime.UtcNow
                        });

                        var orgDets = Utils.MultilingualDataSet(
                            new Dictionary <string, GlobalString>
                        {
                            { "c1", vm.OrgName },
                            { "c2", vm.ContactInfo.Address },
                            { "c3", otherIndustry }
                        });

                        foreach (var r in orgDets)
                        {
                            org.OrganizationDetails_Det.Add(new OrganizationDetails_Det()
                            {
                                LanguageID        = r["c1"].L,
                                OrganizationName  = r["c1"].T,
                                Address           = r["c2"].T,
                                OtherIndustryType = r["c3"].T
                            });
                        }

                        org.OrganizationContact_Info.Add(new OrganizationContact_Info()
                        {
                            UserID     = userId,
                            JobTitleID = "admin",
                            Telephone  = telephoneNo,
                            Mobile     = "",
                            Email      = vm.UserName,
                            AuthorizationletterPath = vm.AuthLetterFileName,
                            IsApproved = (byte)vm.Approval,
                            PostDate   = DateTime.UtcNow,
                            PostUSerID = userId
                        });

                        db.SaveChanges();
                        transaction.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }

            return(vm.PortalUserId);
        }
Пример #6
0
 public static GlobalString Reduce(this GlobalString gs, int langId)
 {
     return(gs.ToReducedCopy((Language)langId, true));
 }
Пример #7
0
 public static bool HasNoValue(this GlobalString gstr)
 {
     return(gstr.IsNullOrWhiteSpace());
 }
Пример #8
0
 public static void SetGlobal(GlobalString global, string value)
 {
     globalStrings[global] = value;
 }
Пример #9
0
 public static string GetGlobal(GlobalString global)
 {
     return(globalStrings[global]);
 }