public void Delete(int id) { var profile = profileRepository.GetById(id); if (profile != null) { profileRepository.Delete(profile); } else { throw new ArgumentException($"Profile with id {id} does not exist."); } }
public async Task <IActionResult> LikePost(int profileId, int id, int actionId) { if (actionId != 0 && actionId != 1) { return(BadRequest()); } string action = actionId == 0 ? "dislike" : "like"; if (profileId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var PostFromRepo = await _repo.GetPost(id); var ProfileFromRepo = await _repo.getProfile(profileId); if (PostFromRepo == null || ProfileFromRepo == null) { return(NotFound()); } var likeFromRepo = await _repo.GetLike(profileId, id); if (likeFromRepo == null) { var like = new Postlike { PostId = id, LikerId = profileId, Reaction = action }; _repo.Add(like); } else if (likeFromRepo.Reaction == action) { _repo.Delete(likeFromRepo); } else { likeFromRepo.Reaction = action; } if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to " + action + " Post")); }
public void DeleteProfile(int id) { var profile = GetProfile(id); _iProfileRepository.Delete(profile); Save(); }
public async Task <IActionResult> DeleteOneProfile([FromRoute] Guid id) { var profileToDelete = await _profileRepository.GetFirstByExpressionAsync(x => x.Id == id); if (profileToDelete == null) { var err = new ErrorObject() { Method = "DELETE", At = $"/api/profiles/{id}", StatusCode = 404, Error = "Could not find profile to delete" }; return(NotFound(err)); } _profileRepository.Delete(profileToDelete); if (!await _profileRepository.SaveAsync()) { var errMsg = "Error deleting a profile"; _logger.Error(errMsg); var err = new ErrorObject() { Method = "DELETE", At = $"/api/profiles/{id}", StatusCode = 500, Error = errMsg }; return(StatusCode(500, err)); } return(NoContent()); }
public async Task <IActionResult> Delete(int id = 0) { // Profile profile = null; if (!(id > 0)) { return(BadRequest()); } /* * try * { * profile = _db.Profiles.First(p => p.Id == id); * } * catch (Exception ex) * { * _logger.LogError("Delete failed, id not found", ex); * return NotFound(); * } */ // _db.Profiles.Remove(profile); // _db.Entry(profile).State = EntityState.Deleted; // await _db.SaveChangesAsync(); _profileRepo.Delete(id); return(Ok("Deleted the profile successfully")); }
public int Delete(Profile profile) { var deleteProfile = GetProfile(profile.Id); _iProfileRepository.Delete(deleteProfile); return(Save()); }
public IActionResult Delete(int?id) { if (id == null) { return(BadRequest()); } _repository.Delete((int)id); return(Ok()); }
public void Delete(int id) { if (_movieService.GetAllMovies().Any(c => c.ProfileId == id) || _netImportFactory.All().Any(c => c.ProfileId == id)) { throw new ProfileInUseException(id); } _profileRepository.Delete(id); }
public ActionResult Delete(long id) { const string title = "El perfil ha sido Eliminado"; var profile = _profileRepository.Delete(id); var content = profile.FullName + " ha sido eliminado exitosamente."; _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage); return(RedirectToAction("Index")); }
public void Delete(int id) { if (_seriesService.GetAllSeries().Any(c => c.ProfileId == id)) { throw new ProfileInUseException(id); } _profileRepository.Delete(id); }
public IResponse Execute(SessionContext sessionContext, string parameter) { if (string.IsNullOrWhiteSpace(parameter)) { return(new Response(ResponseType.BadParameters)); } profileRepository.Delete(parameter); return(new Response(ResponseType.Ok)); }
public void Delete(int id) { if (_seriesService.GetAllSeries().Any(c => c.QualityProfileId == id) || _importListFactory.All().Any(c => c.QualityProfileId == id)) { var profile = _profileRepository.Get(id); throw new QualityProfileInUseException(profile.Name); } _profileRepository.Delete(id); }
public void Remove(Profile profile) { try { repository.Delete(profile); } catch (Exception e) { logger.LogError(e.Message); } }
public async Task <IActionResult> Delete(int id) { if (ModelState.IsValid) { var city = _cityRepository.GetCity(id); _cityRepository.Delete(city); return(Json(new { html = Helper.RenderRazorViewToString(this, "_ViewAll", _cityRepository.GetCities()) })); } return(View()); }
public void Delete(int id) { if (_artistService.GetAllArtists().Any(c => c.QualityProfileId == id) || _importListFactory.All().Any(c => c.ProfileId == id) || _rootFolderService.All().Any(c => c.DefaultQualityProfileId == id)) { var profile = _profileRepository.Get(id); throw new QualityProfileInUseException(profile.Name); } _profileRepository.Delete(id); }
public async Task <Unit> Handle(UnbindProfileCommand request, CancellationToken cancellationToken) { Profile profile = new Profile() { RoleId = request.RoleId, UserId = request.UserId }; await profileRepository.Delete(profile, cancellationToken); return(Unit.Value); }
public ActionResult Delete(int id, FormCollection collection) { var profile = _profileRepository.Read(id); try { _profileRepository.Delete(profile); return(RedirectToAction("Index")); } catch { return(View(profile)); } }
public async Task <Profile> Delete(Guid id) { try { var profile = await ProfileExist(id); await _profileRepository.Delete(profile); return(profile); } catch (Exception e) { throw e; } }
public void Delete(int id) { var profile = GetByProfileId(id); if (profile.Pictures.Any()) { var tempPictures = profile.Pictures.Select(x => new { Id = x.PictureId, Path = x.Path, FileName = x.FileName }).ToList(); foreach (var pic in tempPictures) { PictureService.Delete(pic.Path, pic.FileName); PictureRepository.Delete(pic.Id); } } if (profile.Grunkers.Any()) { var tempGrunks = profile.Grunkers.Select(x => x.GrunkId).ToList(); foreach (var grunkId in tempGrunks) { GrunkRepository.Delete(grunkId); } } if (profile.Purchases.Any()) { var tempPurchases = profile.Purchases.Select(x => new { x.AlbumId, x.ProfileId }).ToList(); foreach (var purchase in tempPurchases) { ProductService.DeletePurchase(purchase.AlbumId, purchase.ProfileId); } } if (profile.ProfileActivities.Any()) { var tempActivities = profile.ProfileActivities.ToList(); foreach (var activityId in tempActivities) { ProfileActivityRepository.Delete(activityId.ActivityId); } } ReviewService.DeleteByProfileId(id); ProfileRepository.Delete(id); CredentialService.DeleteById(profile.CredentialsId); }
public ResponseMessage Delete(int id) { ResponseMessage response = new ResponseMessage(); try { response.IsSuccess = _profileRepository.Delete(id); response.ErrorMessage = "Success"; } catch (Exception ex) { response.IsSuccess = false; response.ErrorMessage = ex.Message; } return(response); }
public async Task <DeleteProfileCommandResult> Handle(DeleteProfileCommand command, CancellationToken cancellationToken) { var profile = await _profileRepository.GetById(command.Id); bool response = false; if (!String.IsNullOrEmpty(profile.ProfilePictureUrl)) { string fileName = Path.GetFileName(profile.ProfilePictureUrl); await _fileService.DeleteFileAsync(_masterConfig.AzureStorageConfig.AzureContainer, fileName); } response = await _profileRepository.Delete(command.Id); return(new DeleteProfileCommandResult() { IsSucceed = response }); }
/// <summary> /// 删除用户资料 /// </summary> /// <param name="userProfile">用户资料</param> /// <returns>删除成功返回true,否则返回false</returns> public bool Delete(long userId) { UserProfile userProfile = profileRepository.Get(userId); if (userProfile == null) { return(false); } EventBus <UserProfile> .Instance().OnBefore(userProfile, new CommonEventArgs(EventOperationType.Instance().Delete())); profileRepository.Delete(userProfile); IEnumerable <EducationExperience> educationExperiences = GetEducationExperiences(userId); if (educationExperiences != null) { foreach (var educationExperience in educationExperiences) { educationExperienceRepository.Delete(educationExperience); } } IEnumerable <WorkExperience> workExperiences = GetWorkExperiences(userId); if (workExperiences != null) { foreach (var workExperience in workExperiences) { workExperienceRepository.Delete(workExperience); } } //通过UserId 删除个人标签 TagService tagService = new TagService(TenantTypeIds.Instance().UserProfile()); tagService.DeleteOwnerTag(userId); EventBus <UserProfile> .Instance().OnAfter(userProfile, new CommonEventArgs(EventOperationType.Instance().Delete())); //同时删除教育经历、工作经历、个人标签、头像文件等 return(true); }
public void DeleteProfile(Guid profileId) { _profileRepository.Delete(profileId); }
public void DeleteUser(UserEntity user) { profileRepository.Delete(profileRepository.GetById(user.Id)); userRepository.Delete(user.ToDalUser()); uow.Commit(); }
public _ReturnProc Delete(string profileId) { m_ProfileRepository.PersonId = this.PersonId; return(m_ProfileRepository.Delete(profileId)); }
public static void DeleteProfile() { ProfileRepository.Delete(Profile); }
public async Task Delete(int id) { _ProfileRepository.Delete(id); await _ProfileRepository.Save(); }
public Domain.Entities.Profile Delete(Domain.Entities.Profile objectInstance) { return(_ProfileRepository.Delete(objectInstance)); }
public ActionResult Delete(Profile profile) { _profileRepository.Delete(profile.Id); return(RedirectToAction("Index")); }
public async Task Delete(Guid profileId) { await _profileRepository.Delete(profileId); }