public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } var experience = _experienceRepository.GetExperienceById(id.Value); if (experience == null) { return(NotFound($"Unable to load experience with ID '{id}'.")); } try { _experienceRepository.DeleteExperience(experience); StatusMessage = "Experience deleted"; return(RedirectToPage("Index")); } catch (Exception ex) { //Log the error var exception = ex; return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }
public bool DeleteExperience(string userId, string experienceId) { try { //Validate user if (_userRepository.IsAuthenticated(userId)) { //GetUserProfile var experience = _experienceRepository.GetExperienceById(experienceId); if (experience != null) { //Success var isDeleted = _experienceRepository.DeleteExperience(experience.Id.ToString()); if (isDeleted) { return(_experienceRepository.Save()); } } _loggingService.Info("Not profile for the user found: " + userId); } _loggingService.Info("UserId Authenticated Failed: " + userId); } catch (Exception ex) { //Error _loggingService.Error("An error has occurred", ex); } //Fail return(false); }
public async Task <IActionResult> DeleteExperience([FromBody] Guid id) { var _experience = await _experienceRepository.DeleteExperience(id); if (_experience == false) { return(NotFound("Experiência não encontrada")); } else { return(Ok(_experience)); } }
public IActionResult Delete(int experienceID, string returnUrl) { var experience = _experienceRepository.DeleteExperience(experienceID); if (User.IsInRole("Admin")) { if (!experience.UserName.Equals(User.Identity.Name)) { return(RedirectToAction("Index", new { category = "Sve kategorije" })); } } return(RedirectToAction("MyList", "Experience")); }
public async Task DeleteExperience(int id) { await _experienceRepository.DeleteExperience(id); }