public ActionResult NewNote(Guid[] jobAdIds, string text) { try { var member = CurrentMember; var noteId = Guid.Empty; // Create them. foreach (var jobAdId in jobAdIds) { var note = new MemberJobAdNote { Text = text, JobAdId = jobAdId, MemberId = member.Id, }; _memberJobAdNotesCommand.CreateNote(member, note); noteId = note.Id; } return(Json(new JsonConfirmationModel { Id = noteId })); } catch (UserException ex) { ModelState.AddModelError(ex, new StandardErrorHandler()); } return(Json(new JsonResponseModel())); }
private static void AssertNote(MemberJobAdNote expectedNote, MemberJobAdNote note) { Assert.AreEqual(expectedNote.Id, note.Id); Assert.AreEqual(expectedNote.MemberId, note.MemberId); Assert.AreEqual(expectedNote.JobAdId, note.JobAdId); Assert.AreEqual(expectedNote.Text, note.Text); }
private MemberJobAdNote CreateNote(int index, IMember noteCreator, Guid memberId) { var note = new MemberJobAdNote { JobAdId = memberId, Text = string.Format(TextFormat, index) }; _memberJobAdNotesCommand.CreateNote(noteCreator, note); return(note); }
void IMemberJobAdNotesCommand.UpdateNote(IMember member, MemberJobAdNote note) { if (!CanUpdateNote(member, note)) { throw new NoteOwnerPermissionsException(member, note.Id); } _jobAdNotesCommand.UpdateNote(note); }
private static bool CanUpdateNote(IHasId <Guid> member, MemberJobAdNote note) { // Must own the note to update it. if (member == null || note == null) { return(false); } return(note.MemberId == member.Id); }
private static bool CanAccessNote(IHasId <Guid> member, MemberJobAdNote note) { if (member == null || note == null) { return(false); } // Must be the owner. return(note.MemberId == member.Id); }
private JobAd CreateJobAd(IMember member, int index, bool isFlagged, bool hasNotes, bool hasBeenViewed, bool hasApplied) { var employer = _employersCommand.CreateTestEmployer(index, _organisationsCommand.CreateTestOrganisation(1)); _jobPostersCommand.CreateJobPoster(new JobPoster { Id = employer.Id }); var jobAd = _jobAdsCommand.PostTestJobAd(employer); // Is flagged. if (isFlagged) { var flagList = _jobAdFlagListsQuery.GetFlagList(member); _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, jobAd.Id); } // Has notes. if (hasNotes) { var note = new MemberJobAdNote { JobAdId = jobAd.Id, Text = "A note" }; _memberJobAdNotesCommand.CreateNote(member, note); } // Has been viewed. if (hasBeenViewed) { _jobAdViewsCommand.ViewJobAd(member.Id, jobAd.Id); } // Has applied. if (hasApplied) { var application = new InternalApplication { PositionId = jobAd.Id, ApplicantId = member.Id, CoverLetterText = "Cover letter" }; _jobAdApplicationSubmissionsCommand.CreateApplication(jobAd, application); _jobAdApplicationSubmissionsCommand.SubmitApplication(jobAd, application); } return(jobAd); }
public void TestFilterHasNotes() { var employer = CreateEmployer(0); var jobAd1 = _jobAdsCommand.PostTestJobAd(employer); var jobAd2 = _jobAdsCommand.PostTestJobAd(employer); var member = _membersCommand.CreateTestMember(1); // Member1 has notes. var note = new MemberJobAdNote { JobAdId = jobAd1.Id, Text = "A note" }; _memberJobAdNotesCommand.CreateNote(member, note); // Filter. TestFilter(member, CreateHasNotesQuery, new[] { jobAd1.Id, jobAd2.Id }, new[] { jobAd1.Id }, new[] { jobAd2.Id }); }
public void TestFilterBlockHasNotes() { var employer = CreateEmployer(0); var jobAd = _jobAdsCommand.PostTestJobAd(employer); var member = _membersCommand.CreateTestMember(1); // Member has notes. var note = new MemberJobAdNote { JobAdId = jobAd.Id, Text = "A note" }; _memberJobAdNotesCommand.CreateNote(member, note); // Filter. TestFilter(new[] { jobAd.Id }, member, CreateHasNotesQuery(true), new[] { jobAd.Id }); // Block. _memberJobAdListsCommand.AddJobAdToBlockList(member, _jobAdBlockListsQuery.GetBlockList(member), jobAd.Id); TestFilter(new Guid[0], member, CreateHasNotesQuery(true), new[] { jobAd.Id }); }
private static void Prepare(IHasId <Guid> member, MemberJobAdNote note) { note.MemberId = member.Id; }
bool IMemberJobAdNotesCommand.CanUpdateNote(IMember member, MemberJobAdNote note) { return(CanUpdateNote(member, note)); }
bool IMemberJobAdNotesCommand.CanDeleteNote(IMember member, MemberJobAdNote note) { // Same thing at the moment. return(CanUpdateNote(member, note)); }
void IMemberJobAdNotesCommand.CreateNote(IMember member, MemberJobAdNote note) { Prepare(member, note); _jobAdNotesCommand.CreateNote(note); }