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); } }
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")); }
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 }); }
/// <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; }
/// <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"); } } } }
/// <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); }