Пример #1
0
        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()));
        }
Пример #2
0
 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);
 }
Пример #3
0
        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);
        }
Пример #4
0
        void IMemberJobAdNotesCommand.UpdateNote(IMember member, MemberJobAdNote note)
        {
            if (!CanUpdateNote(member, note))
            {
                throw new NoteOwnerPermissionsException(member, note.Id);
            }

            _jobAdNotesCommand.UpdateNote(note);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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 });
        }
Пример #9
0
        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 });
        }
Пример #10
0
 private static void Prepare(IHasId <Guid> member, MemberJobAdNote note)
 {
     note.MemberId = member.Id;
 }
Пример #11
0
 bool IMemberJobAdNotesCommand.CanUpdateNote(IMember member, MemberJobAdNote note)
 {
     return(CanUpdateNote(member, note));
 }
Пример #12
0
        bool IMemberJobAdNotesCommand.CanDeleteNote(IMember member, MemberJobAdNote note)
        {
            // Same thing at the moment.

            return(CanUpdateNote(member, note));
        }
Пример #13
0
 void IMemberJobAdNotesCommand.CreateNote(IMember member, MemberJobAdNote note)
 {
     Prepare(member, note);
     _jobAdNotesCommand.CreateNote(note);
 }