public ProfileVm RetrieveProfileVm(string name) { ApplicationUser currentlyLogged = this.RetrieveCurrentUser(name); ProfileVm profileVm = Mapper.Map <ProfileVm>(currentlyLogged); return(profileVm); }
public BsJsonResult GetReadonlyContent(ProfilePanelComponentsEnum componentId) { var html = string.Empty; var msg = string.Empty; var status = BsResponseStatus.Success; try { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); ProfileVm vm = Mapper.Map <ApplicationUser, ProfileVm>(user); switch (componentId) { case ProfilePanelComponentsEnum.UserProfile: html = this.BsRenderPartialView("Readonly/_UserProfile", vm.UserProfile); break; case ProfilePanelComponentsEnum.UserData: html = this.BsRenderPartialView("Readonly/_UserData", vm.UserData); break; } } catch (Exception ex) { msg = ex.Message; status = BsResponseStatus.ServerError; } return(new BsJsonResult(new { Html = html }, status, msg)); }
public ActionResult Profile() { string userName = this.User.Identity.Name; ProfileVm vm = this.service.GetProfileVm(userName); return(this.View(vm)); }
public async Task <IActionResult> Profile(ProfileVm vm) { ClaimsPrincipal currentUser = this.User; var currentUserId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; string uniqueFileName = null; var userName = profileService.GetUserNameById(currentUserId); var user = _context.Users.FirstOrDefault(x => x.UserName == User.Identity.Name); user.Introduction = vm.Introduction; if (vm.Image == null) { profileService.EditProfile(user); } else if (profileService.IsImage(vm.Image) && vm.Image.Length < (3 * 1024 * 1024)) { string uploadFolder = Path.Combine(hostingEnvironment.WebRootPath, "profile-images"); uniqueFileName = Guid.NewGuid().ToString() + "_" + vm.Image.FileName; string filePath = Path.Combine(uploadFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { vm.Image.CopyTo(fileStream); } user.ProfileImagePath = uniqueFileName; profileService.EditProfile(user); } return(RedirectToAction(nameof(Profile))); }
public async Task <IActionResult> Edit(ProfileVm vm) { try { var user1 = await userManager.FindByIdAsync(vm.Id); if (user1 == null) { ViewBag.ErrorMessage = $"User with Id={vm.Id} cannot be found"; return(View("NotFound")); } else { if (vm.Imgfile != null) { string ext = Path.GetExtension(vm.Imgfile.FileName).ToLower(); if (ext == ".jpg" || ext == ".png" || ext == ".jpeg") { var filename = Path.GetFileNameWithoutExtension(vm.Imgfile.FileName) + "_ " + Guid.NewGuid() + ext; var filePath = Path.Combine(hosting.WebRootPath, "images\\ProfilePic", filename); using (var fileStream = new FileStream(filePath, FileMode.Create)) { vm.Imgfile.CopyTo(fileStream); user1.ImagePath = "\\images\\ProfilePic\\" + filename; } } } else { user1.ImagePath = vm.ImagePath; } user1.Id = vm.Id; user1.UserName = vm.UserName; user1.Email = vm.Email; user1.SecurityStamp = vm.SecurityStamp; user1.PhoneNumber = vm.PhoneNumber; IdentityResult result = await userManager.UpdateAsync(user1); if (result.Succeeded) { return(RedirectToAction("Index")); } foreach (var e in result.Errors) { ModelState.AddModelError("", e.Description); } } } catch (Exception ex) { ViewBag.Result = ex.Message; } return(View(vm)); }
public ActionResult Index() { var user = this.HttpContext.User.Identity; ProfileVm profile = _mapper.Map <ProfileVm>(_userService.Get(user.GetUserId())); profile.Reservations = _reservationService.GetByUser(user.GetUserId()).Select(x => _mapper.Map <ReservationVm>(x)); return(View("Account", profile)); }
public ActionResult Signup(ProfileVm model) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, Error); return(View("Signup", model)); } return(View("Signup", model)); }
public ProfileVm GetProfileVm(string userName) { ApplicationUser currentUser = this.Context.Users.FirstOrDefault(user => user.UserName == userName); ProfileVm vm = Mapper.Map <ApplicationUser, ProfileVm>(currentUser); Trainer trainer = this.Context.Trainers.FirstOrDefault(tr => tr.User.Id == currentUser.Id); vm.EnrolledCompetitions = Mapper.Map <IEnumerable <Competition>, IEnumerable <UserCompetitionVm> >(trainer.Competitions); return(vm); }
public ProfileVm GetProfileVm(string username) { ApplicationUser currentUser = this.Context.Users.FirstOrDefault(user => user.UserName == username); ProfileVm vm = Mapper.Map <ApplicationUser, ProfileVm>(currentUser); Student currentStudent = this.Context.Students.FirstOrDefault(student => student.User.Id == currentUser.Id); vm.EnrolledCourses = Mapper.Map <IEnumerable <Course>, IEnumerable <UserCourseVm> >(currentStudent.Courses); return(vm); }
public ProfileVm GetProfileVm(string userName) { ApplicationUser currentUser = this.Context.Users.FirstOrDefault( user => user.UserName == userName); ProfileVm vm = Mapper.Map <ApplicationUser, ProfileVm>(currentUser); Bodybulder currentBodybuilder = this.Context.Bodybulders.FirstOrDefault(bodybuilder => bodybuilder.User.Id == currentUser.Id); vm.EnrolledWorkouts = Mapper.Map <IEnumerable <Workout>, IEnumerable <UserWorkoutVm> >(currentBodybuilder.Workouts); return(vm); }
public ActionResult Index() { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); ProfileVm vm = Mapper.Map <ApplicationUser, ProfileVm>(user); RequireJsOptions.Add("uploadUrl", Url.Action("UploadAvatar")); RequireJsOptions.Add("avatarUrl", Url.Action("GetAvatar")); RequireJsOptions.Add("deleteAvatarUrl", Url.Action("DeleteAvatar")); return(View(vm)); }
public ActionResult Profile() { ProfileVm profileVm = new ProfileVm { User = unitOfWork.Membership.Users.Users.Where(x => x.UserName == HttpContext.User.Identity.Name).FirstOrDefault(), AllDemands = unitOfWork.Demands.Get().Count, CompletedDemands = unitOfWork.Demands.Get(x => x.ResultDemand.isFinished == true).Count, UncompletedDemands = unitOfWork.Demands.Get(x => x.ResultDemand.isFinished == false).Count }; return(View(profileVm)); }
public IActionResult Profile(string id) { var vm = new ProfileVm(); ClaimsPrincipal currentUser = this.User; var currentUserId = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; var user = _context.Users.FirstOrDefault(x => x.UserName == id); var imagePath = profileService.GetProfileImagePathByUserId(currentUserId); var introduction = profileService.GetIntroductionByUserId(currentUserId); vm.ImagePath = user.ProfileImagePath; vm.UserName = id; vm.Introduction = user.Introduction; return(View(vm)); }
private Data.Entities.Profile MapVmToEntity(ProfileVm mapSource) { return(new Data.Entities.Profile { TickerSymbol = mapSource.TickerSymbol.ToUpper().Trim(), TickerDescription = mapSource.TickerDescription.Trim(), DividendRate = mapSource.DividendRate, DividendYield = mapSource.DividendYield, DividendFreq = mapSource.DividendFreq, PERatio = mapSource.PE_Ratio, EarningsPerShare = mapSource.EarningsPerShare, UnitPrice = mapSource.UnitPrice, DividendMonths = mapSource.DividendMonths, DividendPayDay = mapSource.DividendPayDay, CreatedBy = mapSource.CreatedBy }); }
public async Task <IActionResult> Edit(string id) { var userID = userManager.GetUserId(HttpContext.User); ApplicationUser user = userManager.FindByIdAsync(userID).Result; var user1 = await userManager.FindByIdAsync(id); ProfileVm vm = new ProfileVm { Id = id, UserName = user.UserName, Email = user.Email, PhoneNumber = user.PhoneNumber, ImagePath = user.ImagePath, SecurityStamp = user.SecurityStamp }; return(View(vm)); }
public ActionResult Details(string userId) { if (userId == null) { return(this.HttpNotFound("Username cannot be empty.")); } bool exists = this.service.UserExists(userId); if (exists) { ProfileVm vm = this.service.GetProfileVmForUser(userId); this.ViewBag.UserId = userId; return(this.View("UserDetails", vm)); } else { return(this.HttpNotFound("User not found.")); } }
public ActionResult Index(ProfileVm model) { return(View("Signup", model)); }
public ActionResult Profile(string name) { ProfileVm profileVm = this.service.RetrieveProfileVm(name); return(View(profileVm)); }
public ActionResult Edit(ProfileVm model) { return(View()); }