public static User Map_DescriptionViewModel_To_User(ChangeDescriptionViewModel model) { return(new User { ID = model.ID, Description = model.Description, }); }
// // GET: /Manage/ManageDescription public ActionResult ChangeDescription() { var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindById(User.Identity.GetUserId()); var model = new ChangeDescriptionViewModel() { ProfileDescription = currentUser.ProfileDescription }; return(View(model)); }
public async Task <ActionResult> AddDescription(ChangeDescriptionViewModel u) { string id = User.Identity.GetUserId(); if (ModelState.IsValid) { var isUpdated = await _proxy.AddDescriptionAsync(Mapping.Mapping.Map_DescriptionViewModel_To_User(u)); if (isUpdated) { return(RedirectToAction("UserProfile", "User", new { id = User.Identity.GetUserId() })); } return(View(u)); } else { return(View(u)); } }
public async Task <ActionResult> ChangeDescription(ChangeDescriptionViewModel model) { if (ModelState.IsValid) { //add the value to the balance var manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext())); var currentUser = manager.FindById(User.Identity.GetUserId()); currentUser.ProfileDescription = model.ProfileDescription; var result = await manager.UpdateAsync(currentUser); if (result.Succeeded) { return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeDescriptionSuccess })); } return(View(model)); } else { return(View(model)); } }
void ChangeMetaData_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { ChangeDescriptionViewModel cdvm = DataContext as ChangeDescriptionViewModel; if (cdvm != null) { this.IsEnabled = true; if (cdvm.ValidComments != null) { if (cdvm.ValidComments.Count > 0) { FixedCommentsSection.Visibility = System.Windows.Visibility.Visible; FirstComment.ItemsSource = cdvm.ValidComments[0]; Binding b = new Binding("FirstFixedComment"); b.Mode = BindingMode.TwoWay; BindingOperations.SetBinding(FirstComment, ComboBox.SelectedItemProperty, b); } if (cdvm.ValidComments.Count > 1) { SecondComment.Visibility = System.Windows.Visibility.Visible; SecondComment.ItemsSource = cdvm.ValidComments[1]; Binding b = new Binding("SecondFixedComment"); b.Mode = BindingMode.TwoWay; BindingOperations.SetBinding(SecondComment, ComboBox.SelectedItemProperty, b); } if (cdvm.ValidComments.Count > 2) { ThirdComment.Visibility = System.Windows.Visibility.Visible; ThirdComment.ItemsSource = cdvm.ValidComments[2]; Binding b = new Binding("ThirdFixedComment"); b.Mode = BindingMode.TwoWay; BindingOperations.SetBinding(ThirdComment, ComboBox.SelectedItemProperty, b); } } } }
public ChangeDescription() { InitializeComponent(); BindingContext = ViewModel = new ChangeDescriptionViewModel(); }