Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RecruiterProfile
- {
- public RecruiterProfile()
- {
- this.JobOffers = new HashSet<JobOffer>();
- this.Matches = new HashSet<Match>();
- this.Messages = new HashSet<Message>();
- this.DislikedJobSeekers = new HashSet<int>();
- this.LikedJobSeekers = new HashSet<int>();
- }
- [Key]
- public int RecruiterProfileId { get; set; }
- public string UserId { get; set; }
- public virtual User User { get; set; }
- public virtual ICollection<JobOffer> JobOffers { get; set; }
- public virtual ICollection<Match> Matches { get; set; }
- public virtual ICollection<Message> Messages { get; set; }
- public ICollection<int> DislikedJobSeekers { get; set; }
- public ICollection<int> LikedJobSeekers { get; set; }
- }
- [HttpPut]
- public IHttpActionResult Like(int id)
- {
- var recruiter = this.data.RecruiterProfiles.All()
- .FirstOrDefault(x => x.UserId == this.CurrentUserId);
- if (recruiter == null)
- {
- return this.BadRequest("You must be a recruiter to do this.");
- }
- if (recruiter.LikedJobSeekers.Contains(id))
- {
- return this.BadRequest("You've already liked this guy.");
- }
- if (recruiter.DislikedJobSeekers.Contains(id))
- {
- recruiter.DislikedJobSeekers.Remove(id);
- }
- recruiter.LikedJobSeekers.Add(id);
- this.data.RecruiterProfiles.Update(recruiter);
- this.data.SaveChanges();
- return this.Ok(recruiter);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement