예제 #1
0
        public static CategorizedUserDTO Map(User user, List <Category> cats)
        {
            CategorizedUserDTO result = new CategorizedUserDTO
            {
                Id         = user.Id,
                Name       = user.Name,
                IdentityId = user.IdentityId,
                Categories = new List <ValuedCategoryDTO>(),
                Teams      = MapLazy(user.Teams),
                Email      = user.Email
            };

            foreach (var cat in cats)
            {
                result.Categories.Add(Map(cat));
                foreach (var s in result.Categories.Last().Skills)
                {
                    foreach (var us in user.Skills.Where(us => us.Skill.Id == s.Skill.Id))
                    {
                        s.Value      = us.Value;
                        s.Id         = us.Id;
                        s.Skill.Name = us.Skill.Name;
                    }
                }
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Gets user with structured skills by its Identity id (string)
        /// </summary>
        /// <param name="id">Identity id</param>
        /// <returns></returns>
        public CategorizedUserDTO GetCategorizedUser(string id)
        {
            var user = Database.Users.GetAll().First(x => x.IdentityId == id);

            var cats = Database.Categories.GetAll();

            CategorizedUserDTO result = Mapper.Map(user, cats.ToList());

            return(result);
        }
예제 #3
0
 public static CategorizedUserViewModel Map(CategorizedUserDTO u)
 {
     return(new CategorizedUserViewModel
     {
         Id = u.Id,
         Name = u.Name,
         Skills = Map(u.Categories),
         Teams = MapLazy(u.Teams),
         IdentityId = u.IdentityId,
         Email = u.Email
     });
 }
예제 #4
0
        /// <summary>
        /// Gets user with categorized skills by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CategorizedUserDTO GetCategorizedUser(int?id)
        {
            if (id == null)
            {
                throw new ValidationException("User id not set", "");
            }

            var user = Database.Users.Get(id.Value);

            if (user == null)
            {
                throw new ValidationException("User not found", "");
            }

            var cats = Database.Categories.GetAll();

            CategorizedUserDTO result = Mapper.Map(user, cats.ToList());

            return(result);
        }