public ActionResult Edit(ProfileEdit model) { if (ModelState.IsValid) { var result = _profileService.Edit(model); return(RedirectToAction("Index", "Home")); } return(View(model)); }
public async Task EditTest() { var fakeRepository = Mock.Of <IProfileRepository>(); var ProfileService = new ProfileService(fakeRepository); var Profile = new Profile() { Id = 1, Age = 18, City = "Almaty", FirstName = "Anvar", LastName = "HunT", Born = DateTime.Now }; await ProfileService.Edit(Profile); }
public ActionResult <Profile> Edit(int id, [FromBody] Profile Profile) { try { Profile.Id = id; string nameIdentifier = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; if (nameIdentifier != null) { Profile.Email = nameIdentifier; return(Ok(value: _profileService.Edit(Profile))); } else { throw new UnauthorizedAccessException("Unauthorized"); } } catch (Exception e) { return(BadRequest(e.Message)); } }