/// <summary>
        /// Actualiza las categorias de los usuarios activos/suspendidos.
        /// </summary>
        /// <returns></returns>
        public virtual async Task <ActionResult> UpdateCategories()
        {
            int update      = 0;
            var lCategories = await this.repository.Categories.AsNoTracking().ToListAsync();

            if (lCategories.Count == 0)
            {
                return(Json(new { success = true, msg = Validation.ThereAreNoCategories }));
            }

            var lUsers = await this.repository.AspNetUsers.AsNoTracking()
                         .Where(u => u.UserNumber.HasValue && u.Birthdate.HasValue && u.CategoryId.HasValue && u.State != AspNetUserState.Disabled).ToListAsync();

            foreach (var item in lUsers)
            {
                Int32    age      = SiteMethods.GetAge(item.Birthdate, DateTime.Now);
                Category category = lCategories.Where(x => x.YearFrom <= age && x.YearTo >= age).FirstOrDefault();
                if (category?.Price > 0)
                {
                    AspNetUser user = await this.repository.AspNetUsers.Where(u => u.Id == item.Id).FirstOrDefaultAsync();

                    if (user.CategoryId != category.Id)
                    {
                        user.CategoryId = category.Id;
                        repository.Entry(user).State = EntityState.Modified;
                        await this.repository.SaveChangesAsync();

                        update++;
                    }
                }
            }
            return(Json(new { success = true, msg = String.Format(Validation.TheyWereUpdated, update, lUsers.Count()) }));
        }
        /// <summary>
        /// Obtiene las Categorias de una Persona (la idea es que siempre retorne una categoria)
        /// </summary>
        /// <param name="birthdate"></param>
        /// <returns></returns>
        public virtual JsonResult GetCategories(string id)
        {
            DateTime        birthdate;
            List <Category> lCategory = new List <Category>();

            if (DateTime.TryParse(id, out birthdate))
            {
                Int32 age = SiteMethods.GetAge(birthdate, DateTime.Now);
                lCategory = repository.Categories.AsNoTracking()
                            .Where(x => x.YearFrom <= age && x.YearTo >= age).ToList();
            }

            return(Json(new SelectList(lCategory, "Id", "Name")));
        }