示例#1
0
        public ActionResult UpdateProfile(uiModel.Person person, FormCollection frm)
        {
            person.Image    = GetPersonImage(person.Avatar);
            person.ImageUrl = GetPersonImageUrl(person.Avatar, LocalImageUrl, person.Twitter, frm["cbTwitter"] == "on");

            service.UpdatePerson(person.Transform());

            this.CurrentUser = person;

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Add(Person admin)
        {
            var p = service.FindPersonByEmail(admin.Email);

            if (p != null)
            {
                service.AddAdministrator(p.ID);

                return RedirectToAction("Index");
            }
            else
            {
                return View(admin);
            }
        }
示例#3
0
        public ActionResult UpdateProfile(uiModel.Person person, FormCollection frm)
        {
            bool useTwitter = frm["cbTwitter"] == "on";

            if (person.Avatar != null)
            {
                person.ImageUrl = GetImageInfo(person.Avatar, "/Content/avatar");
            }
            else if (useTwitter)
            {
                person.ImageUrl = GetImageInfo(person.Twitter, LocalImageUrl);
            }
            else
            {
                person.ImageUrl = LocalImageUrl;
            }

            //string txtAvatarURL = frm["txtAvatarURL"];
            //bool useTwitter = frm["cbTwitter"] == "on";
            //if (useTwitter)
            //    person.ImageUrl = GetImageInfo(person.Twitter, localImageUrl);
            //else
            //    person.ImageUrl = string.IsNullOrEmpty(txtAvatarURL) ? localImageUrl : txtAvatarURL;


            //TODO - Can't update avatar after initial save due to filesystem security
            //if (String.IsNullOrEmpty(person.ImageUrl))
            //{
            //    person.ImageUrl = this.GetImageInfo(person.Avatar);
            //}
            //else
            //{
            //    string tempPersonUri = person.ImageUrl;
            //    person.ImageUrl =
            //        string.Format("{0}.{1}",
            //                      DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture),
            //                      tempPersonUri);
            //    person.Avatar.FileName = person.ImageUrl;
            //}
            service.UpdatePerson(person.Transform());

            this.CurrentUser = person;

            return(RedirectToAction("Index", "Home"));
        }
示例#4
0
 public static Services.Person Transform(this UiModel.Person person)
 {
     return(new Services.Person
     {
         ID = person.ID,
         ImageUrl = person.ImageUrl,
         Website = person.Website,
         Email = person.Email,
         Bio = person.Bio,
         Twitter = person.Twitter,
         Blog = person.Blog,
         Title = person.Title,
         FirstName = person.FirstName,
         LastName = person.LastName,
         IsAdmin = person.IsAdmin,
         Location = person.Location,
         LoginProvider = person.LoginProvider
     });
 }
示例#5
0
 /// <summary>
 /// Maps a CodeCampService.Person to a Model.Person
 /// </summary>
 /// <param name="person"></param>
 /// <returns></returns>
 public static Model.Person Map(Services.Person person)
 {
     var p = new Model.Person
     {
         ID = person.ID,
         ImageUrl = person.ImageUrl,
         Website = person.Website,
         Email = person.Email,
         Bio = person.Bio,
         Twitter = person.Twitter,
         Blog = person.Blog,
         Title = person.Title,
         FirstName = person.FirstName,
         LastName = person.LastName,
         IsAdmin = person.IsAdmin,
         Location = person.Location,
         TShirtSizeId = person.TShirtSize,
         LoginProvider = person.LoginProvider,
     };
     return p;
 }
示例#6
0
        /// <summary>
        /// Maps the roles for a Person based on the existence
        /// of certain properties and flags
        /// </summary>
        /// <param name="p">Model.Person</param>
        /// <param name="speaker">Model.Speaker</param>
        public static void SetRolesForPerson(this Model.Person p, Services.Speaker speaker = null)
        {
            if (p != null)
            {
                if (p.IsAdmin)
                {
                    p.Roles.Add("Admin");
                }
            }

            if (speaker != null)
            {
                if (speaker.Sessions != null)
                {
                    if (speaker.Sessions.Any())
                    {
                        p.Roles.Add("Speaker");
                    }
                }
            }
        }
示例#7
0
        /// <summary>
        /// Maps a CodeCampService.Person to a Model.Person
        /// </summary>
        /// <param name="person"></param>
        /// <returns></returns>
        public static Model.Person Map(Services.Person person)
        {
            var p = new Model.Person
            {
                ID            = person.ID,
                ImageUrl      = person.ImageUrl,
                Website       = person.Website,
                Email         = person.Email,
                Bio           = person.Bio,
                Twitter       = person.Twitter,
                Blog          = person.Blog,
                Title         = person.Title,
                FirstName     = person.FirstName,
                LastName      = person.LastName,
                IsAdmin       = person.IsAdmin,
                Location      = person.Location,
                TShirtSizeId  = person.TShirtSize,
                LoginProvider = person.LoginProvider,
            };

            return(p);
        }