Exemplo n.º 1
0
        public List <StylistListItem> GetListOfStylists()
        {
            using (var ctx = new ApplicationDbContext())
            {
                var role     = ctx.Roles.Single(e => e.Name == "StylistUser").Id;
                var stylists = ctx.Users.ToList();

                var service = new ProfilesService(_userId);

                List <StylistListItem> ListOfStylists = new List <StylistListItem>();
                foreach (var individual in stylists)
                {
                    var m            = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(ctx));
                    var rolesForUser = m.GetRoles(individual.Id).FirstOrDefault();
                    if (rolesForUser == "StylistUser")
                    {
                        var profile = service.GetProfileByUserID(individual.Id);
                        var updated = new StylistListItem
                        {
                            StylistID        = individual.Id,
                            StylistUserName  = individual.UserName,
                            StylistFirstName = profile.FirstName,
                            StylistLastName  = profile.LastName,
                            Photo            = profile.Photo
                        };
                        ListOfStylists.Add(updated);
                    }
                }
                return(ListOfStylists);
            }
        }
Exemplo n.º 2
0
        public StylistDetail GetStylistById(Guid id)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Users
                    .Single(e => e.Id == id.ToString());

                var service = new ProfilesService(_userId);
                var stylist = new StylistDetail
                {
                    StylistID       = entity.Id,
                    StylistUserName = entity.UserName,
                    StylistProfile  = service.GetProfileByUserID(_userId.ToString())
                };
                return(stylist);
            }
        }