예제 #1
0
        public ActionResult Edit(ProfileEdit model)
        {
            if (ModelState.IsValid)
            {
                var result = _profileService.Edit(model);
                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
예제 #2
0
 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);
 }
예제 #3
0
 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));
     }
 }