Exemple #1
0
        public PagedList <Doctor> GetDoctorSearch(string slug, string slugManage, string doctor, int pageIndex, int pageSize)
        {
            if (!string.IsNullOrEmpty(doctor))
            {
                doctor = ServiceHelpers.CreateUrl(doctor.Trim());
            }

            var subDepartment = _context.Department.FirstOrDefault(x => x.Slug == slug);
            var department    = _context.Department.FirstOrDefault(x => x.Slug == slugManage);

            var query = _context.Doctor.AsNoTracking().Where(x => (string.IsNullOrEmpty(slug) || x.DepartmentManage.Slug == slug) && (string.IsNullOrEmpty(doctor) || x.Slug.Contains(doctor))).OrderByDescending(x => x.Name);

            if (subDepartment != null && department != null)
            {
                query = _context.Doctor.AsNoTracking().Where(x => (x.DepartmentManage.Id == subDepartment.Id) && (string.IsNullOrEmpty(doctor) || x.Slug.Contains(doctor))).OrderByDescending(x => x.Name);
            }

            if (subDepartment == null && department != null)
            {
                var childDepartment = _context.Department.AsNoTracking().AsEnumerable().Where(x => x.ParentDepartment != null && x.ParentDepartment.Id == department.Id).ToList();
                query = childDepartment.Count == 0 ? _context.Doctor.AsNoTracking().Where(x => (x.DepartmentManage.Id == department.Id) && (string.IsNullOrEmpty(doctor) || x.Slug.Contains(doctor))).OrderByDescending(x => x.Name) : _context.Doctor.AsNoTracking().Where(x => (x.DepartmentManage.ParentDepartment.Id == department.Id) && (string.IsNullOrEmpty(doctor) || x.Slug.Contains(doctor))).OrderByDescending(x => x.Name);
            }


            var rs = query
                     .OrderBy(x => x.Name)
                     .Skip((pageIndex - 1) * pageSize)
                     .Take(pageSize).Where(x => x.Status.Equals("A") && x.IsSearch)
                     .ToList();

            return(new PagedList <Doctor>(rs, pageIndex, 10, query.Count()));
        }
Exemple #2
0
 public Recruitment Add(Recruitment entity)
 {
     //entity.Slug = ServiceHelpers.CreateUrl(entity.Name.Trim());
     // url slug generator
     entity.Slug = ServiceHelpers.GenerateSlug(entity.Name, GetBySlugLike(ServiceHelpers.CreateUrl(entity.Name)), null);
     return(_context.Recruitment.Add(entity));
 }
Exemple #3
0
        public PagedList <ApplyCV> GetAllPageApplyCV(string recruitmentId, string search, bool isDelete, int pageIndex, int pageSize)
        {
            if (!string.IsNullOrEmpty(search))
            {
                search = ServiceHelpers.CreateUrl(search.Trim());
            }

            if (string.IsNullOrEmpty(recruitmentId))
            {
                var total = _context.ApplyCV.Count(x => string.IsNullOrEmpty(search) || x.Slug.Contains(search) && x.IsDelete.Equals(isDelete));

                var rs = _context.ApplyCV.Where(x => string.IsNullOrEmpty(search) || x.Slug.Contains(search) && x.IsDelete.Equals(isDelete))
                         .Include(x => x.Recruitment)
                         .OrderByDescending(x => x.DateCreated)
                         .Skip((pageIndex - 1) * pageSize)
                         .Take(pageSize)
                         .ToList();

                return(new PagedList <ApplyCV>(rs, pageIndex, 10, total));
            }
            else
            {
                var total = _context.ApplyCV.Count(x => (string.IsNullOrEmpty(search) || x.Slug.Contains(search)) && x.Recruitment.Id.ToString().Equals(recruitmentId) && x.IsDelete.Equals(isDelete));

                var rs = _context.ApplyCV.Where(x => (string.IsNullOrEmpty(search) || x.Slug.Contains(search)) && x.Recruitment.Id.ToString().Equals(recruitmentId) && x.IsDelete.Equals(isDelete))
                         .Include(x => x.Recruitment)
                         .OrderByDescending(x => x.DateCreated)
                         .Skip((pageIndex - 1) * pageSize)
                         .Take(pageSize)
                         .ToList();

                return(new PagedList <ApplyCV>(rs, pageIndex, 10, total));
            }
        }
Exemple #4
0
        /// <summary>
        /// Create a new topic and also the topic starter post
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public Topic Add(Topic topic)
        {
            topic = SanitizeTopic(topic);

            topic.CreateDate = DateTime.UtcNow;

            // url slug generator
            topic.Slug = ServiceHelpers.GenerateSlug(topic.Name, GetTopicBySlugLike(ServiceHelpers.CreateUrl(topic.Name)), null);

            return(_context.Topic.Add(topic));
        }
Exemple #5
0
        public List <ApplyCV> GetAllApplyCVByReId(string recruitmentId, string search)
        {
            if (!string.IsNullOrEmpty(search))
            {
                search = ServiceHelpers.CreateUrl(search.Trim());
            }

            return(_context.ApplyCV.Where(x => (string.IsNullOrEmpty(search) || x.Slug.Contains(search)) && x.Recruitment.Id.ToString().Equals(recruitmentId))
                   .Include(x => x.Recruitment)
                   .OrderByDescending(x => x.DateCreated)
                   .ToList());
        }
Exemple #6
0
        /// <summary>
        /// Add a new category
        /// </summary>
        /// <param name="category"></param>
        public Category Add(Category category)
        {
            // Sanitize
            category = SanitizeCategory(category);

            // Set the create date
            category.DateCreated = DateTime.UtcNow;

            // url slug generator
            category.Slug = ServiceHelpers.GenerateSlug(category.Name, GetBySlugLike(ServiceHelpers.CreateUrl(category.Name)), null);

            // Add the category
            return(_context.Category.Add(category));
        }
Exemple #7
0
        public PagedList <Recruitment> GetAllPageRecruitment(string search, bool isPending, int pageIndex, int pageSize)
        {
            if (!string.IsNullOrEmpty(search))
            {
                search = ServiceHelpers.CreateUrl(search.Trim());
            }
            var rs = _context.Recruitment.Where(x => (string.IsNullOrEmpty(search) || x.Slug.Contains(search)) && x.IsPending == false)
                     .OrderByDescending(x => x.DateCreated)
                     .Skip((pageIndex - 1) * pageSize)
                     .Take(pageSize)
                     .ToList();

            return(new PagedList <Recruitment>(rs, pageIndex, 10, rs.Count));
        }
Exemple #8
0
        /// <summary>
        /// Add new tags to a topic, ignore existing ones
        /// </summary>
        /// <param name="tags"></param>
        /// <param name="topic"></param>
        public void Add(string tags, Topic topic)
        {
            if (!string.IsNullOrEmpty(tags))
            {
                tags = StringUtils.SafePlainText(tags);

                var splitTags = tags.Replace(" ", "").Split(',');

                if (topic.Tags == null)
                {
                    topic.Tags = new List <TopicTag>();
                }

                var newTagNames  = splitTags.Select(tag => tag);
                var newTags      = new List <TopicTag>();
                var existingTags = new List <TopicTag>();

                foreach (var newTag in newTagNames.Distinct())
                {
                    var tag = _tagRepository.GetTagName(newTag);
                    if (tag != null)
                    {
                        // Exists
                        existingTags.Add(tag);
                    }
                    else
                    {
                        // Doesn't exists
                        var nTag = new TopicTag
                        {
                            Tag  = newTag,
                            Slug = ServiceHelpers.CreateUrl(newTag)
                        };

                        _tagRepository.Add(nTag);
                        newTags.Add(nTag);
                    }
                }

                newTags.AddRange(existingTags);
                topic.Tags = newTags;

                // Fire the tag badge check
                _badgeService.ProcessBadge(BadgeType.Tag, topic.User);
            }
        }
Exemple #9
0
        public PagedList <Topic> SearchPendingTopics(string search, int pageIndex, int pageSize, List <Category> allowedCategories)
        {
            var slug = ServiceHelpers.CreateUrl(search);

            // get the category ids
            var allowedCatIds = allowedCategories.Select(x => x.Id);

            var total = _context.Topic
                        .Count(x => x.Slug.Contains(slug) && x.Pending == true && allowedCatIds.Contains(x.Category.Id));

            // Get the topics using an efficient
            var results = _context.Topic
                          .Where(x => x.Slug.Contains(slug) && x.Pending == true && allowedCatIds.Contains(x.Category.Id))
                          .OrderBy(x => x.Name)
                          .Skip((pageIndex - 1) * pageSize)
                          .Take(pageSize)
                          .ToList();

            // Return a paged list
            return(new PagedList <Topic>(results, pageIndex, pageSize, total));
        }
Exemple #10
0
 public Doctor Add(Doctor doctor)
 {
     doctor.Status = "A";
     doctor.Slug   = ServiceHelpers.GenerateSlug(doctor.Name, GetDoctorBySlugLike(ServiceHelpers.CreateUrl(doctor.Name)), null);
     return(_context.Doctor.Add(doctor));
 }
        /// <summary>
        /// Add a new category
        /// </summary>
        /// <param name="category"></param>
        public void Add(Category category)
        {
            // Sanitize
            category = SanitizeCategory(category);

            // Set the create date
            category.DateCreated = DateTime.UtcNow;

            // url slug generator
            category.Slug = ServiceHelpers.GenerateSlug(category.Name, _categoryRepository.GetBySlugLike(ServiceHelpers.CreateUrl(category.Name)), null);

            // Add the category
            _categoryRepository.Add(category);
        }
Exemple #12
0
        /// <summary>
        /// Create a new topic and also the topic starter post
        /// </summary>
        /// <param name="topic"></param>
        /// <returns></returns>
        public Topic Add(Topic topic)
        {
            topic = SanitizeTopic(topic);

            topic.CreateDate = DateTime.UtcNow;

            // url slug generator
            topic.Slug = ServiceHelpers.GenerateSlug(topic.Name, x => _topicRepository.GetTopicBySlugLike(ServiceHelpers.CreateUrl(topic.Name)));

            return(_topicRepository.Add(topic));
        }
Exemple #13
0
        /// <summary>
        /// Extract users from CSV format and import them
        /// </summary>
        /// <returns></returns>
        public CsvReport FromCsv(List <string> allLines)
        {
            var usersProcessed = new List <string>();
            var commaSeparator = new[] { ',' };
            var report         = new CsvReport();

            if (allLines == null || allLines.Count == 0)
            {
                report.Errors.Add(new CsvErrorWarning
                {
                    ErrorWarningType = CsvErrorWarningType.BadDataFormat,
                    Message          = "No users found."
                });
                return(report);
            }

            var lineCounter = 0;

            foreach (var line in allLines)
            {
                try
                {
                    lineCounter++;

                    // Each line is made up of n items in a predefined order

                    var values = line.Split(commaSeparator);

                    if (values.Length < 2)
                    {
                        report.Errors.Add(new CsvErrorWarning
                        {
                            ErrorWarningType = CsvErrorWarningType.MissingKeyOrValue,
                            Message          = string.Format("Line {0}: insufficient values supplied.", lineCounter)
                        });

                        continue;
                    }

                    var userName = values[0];

                    if (userName.IsNullEmpty())
                    {
                        report.Errors.Add(new CsvErrorWarning
                        {
                            ErrorWarningType = CsvErrorWarningType.MissingKeyOrValue,
                            Message          = string.Format("Line {0}: no username supplied.", lineCounter)
                        });

                        continue;
                    }

                    var email = values[1];
                    if (email.IsNullEmpty())
                    {
                        report.Errors.Add(new CsvErrorWarning
                        {
                            ErrorWarningType = CsvErrorWarningType.MissingKeyOrValue,
                            Message          = string.Format("Line {0}: no email supplied.", lineCounter)
                        });

                        continue;
                    }

                    // get the user
                    var userToImport = _membershipRepository.GetUser(userName);

                    if (userToImport != null)
                    {
                        report.Errors.Add(new CsvErrorWarning
                        {
                            ErrorWarningType = CsvErrorWarningType.AlreadyExists,
                            Message          = string.Format("Line {0}: user already exists in forum.", lineCounter)
                        });

                        continue;
                    }

                    if (usersProcessed.Contains(userName))
                    {
                        report.Errors.Add(new CsvErrorWarning
                        {
                            ErrorWarningType = CsvErrorWarningType.AlreadyExists,
                            Message          = string.Format("Line {0}: user already exists in import file.", lineCounter)
                        });

                        continue;
                    }

                    usersProcessed.Add(userName);

                    userToImport              = CreateEmptyUser();
                    userToImport.UserName     = userName;
                    userToImport.Slug         = ServiceHelpers.GenerateSlug(userToImport.UserName, _membershipRepository.GetUserBySlugLike(ServiceHelpers.CreateUrl(userToImport.UserName)), userToImport.Slug);
                    userToImport.Email        = email;
                    userToImport.IsApproved   = true;
                    userToImport.PasswordSalt = StringUtils.CreateSalt(AppConstants.SaltSize);

                    string createDateStr = null;
                    if (values.Length >= 3)
                    {
                        createDateStr = values[2];
                    }
                    userToImport.CreateDate = createDateStr.IsNullEmpty() ? DateTime.UtcNow : DateTime.Parse(createDateStr);

                    if (values.Length >= 4)
                    {
                        userToImport.Age = Int32.Parse(values[3]);
                    }
                    if (values.Length >= 5)
                    {
                        userToImport.Location = values[4];
                    }
                    if (values.Length >= 6)
                    {
                        userToImport.Website = values[5];
                    }
                    if (values.Length >= 7)
                    {
                        userToImport.Facebook = values[6];
                    }
                    if (values.Length >= 8)
                    {
                        userToImport.Signature = values[7];
                    }

                    _membershipRepository.Add(userToImport);
                }
                catch (Exception ex)
                {
                    report.Errors.Add(new CsvErrorWarning {
                        ErrorWarningType = CsvErrorWarningType.GeneralError, Message = ex.Message
                    });
                }
            }

            return(report);
        }
Exemple #14
0
        /// <summary>
        /// Create new user
        /// </summary>
        /// <param name="newUser"></param>
        /// <returns></returns>
        public MembershipCreateStatus CreateUser(MembershipUser newUser)
        {
            newUser = SanitizeUser(newUser);
            var settings = _settingsRepository.GetSettings(true);

            var status = MembershipCreateStatus.Success;

            var e = new RegisterUserEventArgs {
                User = newUser
            };

            EventManager.Instance.FireBeforeRegisterUser(this, e);

            if (e.Cancel)
            {
                status = e.CreateStatus;
            }
            else
            {
                if (string.IsNullOrEmpty(newUser.UserName))
                {
                    status = MembershipCreateStatus.InvalidUserName;
                }

                // get by username
                if (_membershipRepository.GetUser(newUser.UserName) != null)
                {
                    status = MembershipCreateStatus.DuplicateUserName;
                }

                // Add get by email address
                if (_membershipRepository.GetUserByEmail(newUser.Email) != null)
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                }

                if (string.IsNullOrEmpty(newUser.Password))
                {
                    status = MembershipCreateStatus.InvalidPassword;
                }

                if (status == MembershipCreateStatus.Success)
                {
                    // Hash the password
                    var salt = StringUtils.CreateSalt(AppConstants.SaltSize);
                    var hash = StringUtils.GenerateSaltedHash(newUser.Password, salt);
                    newUser.Password     = hash;
                    newUser.PasswordSalt = salt;

                    newUser.Roles = new List <MembershipRole> {
                        settings.NewMemberStartingRole
                    };

                    // Set dates
                    newUser.CreateDate      = newUser.LastPasswordChangedDate = DateTime.UtcNow;
                    newUser.LastLockoutDate = (DateTime)SqlDateTime.MinValue;
                    newUser.LastLoginDate   = DateTime.UtcNow;

                    newUser.IsApproved  = !settings.ManuallyAuthoriseNewMembers;
                    newUser.IsLockedOut = false;

                    // url generator
                    newUser.Slug = ServiceHelpers.GenerateSlug(newUser.UserName, _membershipRepository.GetUserBySlugLike(ServiceHelpers.CreateUrl(newUser.UserName)), null);

                    try
                    {
                        _membershipRepository.Add(newUser);

                        if (settings.EmailAdminOnNewMemberSignUp)
                        {
                            var sb = new StringBuilder();
                            sb.AppendFormat("<p>{0}</p>", string.Format(_localizationService.GetResourceString("Members.NewMemberRegistered"), settings.ForumName, settings.ForumUrl));
                            sb.AppendFormat("<p>{0} - {1}</p>", newUser.UserName, newUser.Email);
                            var email = new Email
                            {
                                EmailTo = settings.AdminEmailAddress,
                                NameTo  = _localizationService.GetResourceString("Members.Admin"),
                                Subject = _localizationService.GetResourceString("Members.NewMemberSubject")
                            };
                            email.Body = _emailService.EmailTemplate(email.NameTo, sb.ToString());
                            _emailService.SendMail(email);
                        }

                        _activityService.MemberJoined(newUser);
                        EventManager.Instance.FireAfterRegisterUser(this,
                                                                    new RegisterUserEventArgs {
                            User = newUser
                        });
                    }
                    catch (Exception)
                    {
                        status = MembershipCreateStatus.UserRejected;
                    }
                }
            }

            return(status);
        }
Exemple #15
0
 public ApplyCV AddApplyCV(ApplyCV entity)
 {
     entity.Slug = ServiceHelpers.CreateUrl(entity.FullName.Trim());
     return(_context.ApplyCV.Add(entity));
 }
Exemple #16
0
 public void Update(Recruitment entity)
 {
     entity.Slug = ServiceHelpers.CreateUrl(entity.Name.Trim());
     _context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
 }
Exemple #17
0
        public Department InsertDepartment(Department entity)
        {
            // Sanitize
            entity = SanitizeDepartment(entity);

            // url slug generator
            entity.Slug = ServiceHelpers.GenerateSlug(entity.Name, GetDepartmentBySlugLike(ServiceHelpers.CreateUrl(entity.Name)), null);

            // Add the department
            return(_context.Department.Add(entity));
        }
Exemple #18
0
 public void Update(Doctor updatedoctor)
 {
     if (string.IsNullOrEmpty(updatedoctor.Slug))
     {
         updatedoctor.Slug = ServiceHelpers.GenerateSlug(updatedoctor.Name, GetDoctorBySlugLike(ServiceHelpers.CreateUrl(updatedoctor.Name)), null);
     }
     _context.Entry(updatedoctor).State = System.Data.Entity.EntityState.Modified;
 }
Exemple #19
0
        public List <Department> GetListDepartmentBySlug(string search)
        {
            var convertToSlug = ServiceHelpers.CreateUrl(search);

            return(_context.Department.Where(x => x.Slug.Contains(convertToSlug)).ToList());
        }
Exemple #20
0
 public Education Add(Education entity)
 {
     entity.Slug = ServiceHelpers.CreateUrl(entity.Name.Trim());
     return(_context.Education.Add(entity));
 }
Exemple #21
0
        public MedicalPackage InsertMedicalPackage(MedicalPackage entity)
        {
            // Sanitize
            entity = SanitizeMedicalPackage(entity);

            // url slug generator
            entity.Slug = ServiceHelpers.GenerateSlug(entity.Name, GetMedicalPackageBySlugLike(ServiceHelpers.CreateUrl(entity.Name)), null);

            // Add the department
            return(_context.MedicalPackage.Add(entity));
        }