public EditProfileInput(Profile profile)
 {
     Username = profile.Username;
     FirstName = profile.FirstName;
     LastName = profile.LastName;
     Email = profile.Email;
 }
Example #2
0
 public ProfileEditModel(Profile profile)
 {
     Username = profile.Username;
     FirstName = profile.FirstName;
     LastName = profile.LastName;
     Email = profile.Email;
 }
Example #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            var repository = new ProfileRepository();

            var firstNames = new[]
            {
                "Jacob", "Michael", "Ethan", "Joshua", "Daniel", "Alexander", "Anthony", "William", "Chris", "Matthew", "Emma",
                "Isabella", "Emily", "Madison", "Ava", "Olivia", "Sofia", "Abigail", "Elizabeth", "Chloe"
            };
            var lastNames = new[]
            {
                "Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson",
                "Thomas", "Jackson", "White", "Harris", "Martin", "Thompson", "Robinson", "Clark", "Lewis", "Lee", "Walker"
            };

            var rand = new Random((int) DateTime.Now.Ticks);

            for (int i = 0; i < 100; i++)
            {
                var firstName = firstNames[rand.Next(firstNames.Length)];
                var lastName = lastNames[rand.Next(lastNames.Length)];
                var username = Guid.NewGuid().ToString().Substring(0, 8);
                var profile = new Profile(username) {FirstName = firstName, LastName = lastName};

                repository.Add(profile);
            }

            InputBuilder.BootStrap();
            InputBuilder.SetPropertyConvention(() => new InputBuilderPropertyFactory());
        }
        public ViewResult Show(string username)
        {
            var profile = _profileRepository.Find(username);
            if (profile == null)
            {
                profile = new Profile(username);
                _profileRepository.Add(profile);
            }

            return View(profile);
        }
        public ViewResult Show(string username)
        {
            var profile = _profileRepository.Find(username);
            if (profile == null)
            {
                profile = new Profile(username);
                _profileRepository.Add(profile);
            }

            bool hasPermission = User.Identity.Name == username;

            ViewData["hasPermission"] = hasPermission;

            return View(profile);
        }
Example #6
0
 public void Add(Profile profile)
 {
     _profiles.Add(profile);
 }
 public LogOnWidgetModel(bool isAuthenticated, Profile profile)
 {
     IsAuthenticated = isAuthenticated;
     Profile = profile;
 }
        public Profile Find(string username)
        {
            var profile = _profiles.FirstOrDefault(p => p.Username == username);
            if (profile == null)
            {
                profile = new Profile(username);
                Add(profile);
            }

            return profile;
        }
        public ViewResult LogOnWidget()
        {
            bool isAuthenticated = Request.IsAuthenticated;
            Profile profile = null;

            if (isAuthenticated)
            {
                var username = HttpContext.User.Identity.Name;
                profile = _profileRepository.Find(username);
                if (profile == null)
                {
                    profile = new Profile(username);
                    _profileRepository.Add(profile);
                }
            }

            return View(new LogOnWidgetModel(isAuthenticated, profile));
        }