public List <JinderPoster> GetPosters(String Username, [FromUri] int count) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; JinderUser jinderuser = (from user in usersTable where user.username == Username select user).FirstOrDefault <JinderUser>(); if (jinderuser.UserType != "seeker") { throw new Exception(" JinderUser with username: "******" is not a seeker"); } var viewedJobPost = from log in dbContext.ExpressionLogs where log.SourceUserId == jinderuser.JinderUserId select log.TargetUserId; var notViewedJobs = (from jobpost in dbContext.JobPosts where !viewedJobPost.Contains(jobpost.JobPostId) select jobpost).Take <JobPost>(count); List <JinderPoster> jobPosts = new List <JinderPoster>(); foreach (JobPost post in notViewedJobs) { JinderPoster jp = new JinderPoster(); jp.JobDescription = post.JobDescription; jobPosts.Add(jp); } return(jobPosts); }
public IHttpActionResult PutJinderUser(int id, JinderUser jinderUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != jinderUser.JinderUserId) { return(BadRequest()); } db.Entry(jinderUser).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!JinderUserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public List <JinderSeeker> GetSeekers(String Username, [FromUri] int count) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; JinderUser jinderuser = (from user in usersTable where user.username == Username select user).FirstOrDefault <JinderUser>(); if (jinderuser.UserType != "poster") { throw new Exception(" JinderUser with username: "******" is not a poster"); } var viewedSeekers = from log in dbContext.ExpressionLogs where log.SourceUserId == jinderuser.JinderUserId select log.TargetUserId; //var viewedIds = viewedSeekers.ToList(); var notViewedSeekers = (from seeker in usersTable where seeker.UserType == "seeker" && !viewedSeekers.Contains(seeker.JinderUserId) select seeker).Take <JinderUser>(count); List <JinderSeeker> jinderSeekers = new List <JinderSeeker>(); foreach (JinderUser seeker in notViewedSeekers) { JinderSeeker js = new JinderSeeker(); js.username = seeker.username; jinderSeekers.Add(js); } return(jinderSeekers); }
public List <JinderSeeker> Get(String Username, [FromUri] int count, int dummy = 0) { JinderDBConnection dbContext = new JinderDBConnection(); var usersTable = dbContext.JinderUsers; JinderUser jinderUser = (from user in usersTable where user.Username == Username select user).FirstOrDefault <JinderUser>(); if (jinderUser.UserType != "poster") { throw new Exception("JinderUser with username: "******" is not a poster!"); } var viewedSeekerIds = from log in dbContext.PosterExpressionLogs where log.PosterId == jinderUser.JinderUserId select log.SeekerId; var notViewedSeekers = (from seeker in dbContext.JinderUsers where seeker.UserType == "seeker" && !viewedSeekerIds.Contains <int>(seeker.JinderUserId) select seeker).Take <JinderUser>(count); List <JinderSeeker> jinderSeekers = new List <JinderSeeker>(); foreach (JinderUser seeker in notViewedSeekers) { jinderSeekers.Add(JinderSeeker.getJinderSeeker(seeker)); } return(jinderSeekers); }
public List <SimpleJobPost> Get(String Username, [FromUri] int count) { JinderDBConnection dbContext = new JinderDBConnection(); var usersTable = dbContext.JinderUsers; JinderUser jinderUser = (from user in usersTable where user.Username == Username select user).FirstOrDefault <JinderUser>(); if (jinderUser.UserType != "seeker") { throw new Exception("JinderUser with username: "******" is not a seeker!"); } var viewedJobPostIds = from id in dbContext.SeekerExpressionLogs where id.SeekerId == jinderUser.JinderUserId select id.JobPostId; var notViewedJobPosts = (from jobPost in dbContext.JobPosts where !viewedJobPostIds.Contains <int>(jobPost.JobPostId) select jobPost).Take <JobPost>(count); List <SimpleJobPost> simpleJobPosts = new List <SimpleJobPost>(); foreach (JobPost post in notViewedJobPosts) { simpleJobPosts.Add(SimpleJobPost.getSimpleJobPost(post)); } return(simpleJobPosts); }
public IHttpActionResult GetJinderUser(int id) { JinderUser jinderUser = db.JinderUsers.Find(id); if (jinderUser == null) { return(NotFound()); } return(Ok(jinderUser)); }
public IHttpActionResult PostJinderUser(JinderUser jinderUser) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.JinderUsers.Add(jinderUser); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = jinderUser.JinderUserId }, jinderUser)); }
public HttpResponseMessage Post([FromBody] SignupInfo info) { JinderDBConnection dbContext = new JinderDBConnection(); var usersTable = dbContext.JinderUsers; JinderUser jinderUser = (from user in usersTable where user.Username == info.Username select user).FirstOrDefault <JinderUser>(); HttpResponseMessage message = new HttpResponseMessage(); if (jinderUser != null) { message.StatusCode = HttpStatusCode.Conflict; message.Content = new StringContent("Username: "******" is already registered."); return(message); } JinderUser newUser = new JinderUser(); newUser.Username = info.Username; newUser.Password = info.Password; newUser.FullName = info.FullName; newUser.DateOfBirth = info.DateOfBirth; newUser.ProfilePicture = info.ProfilePicture; newUser.Gender = info.Gender; newUser.Address = info.Address; newUser.UserType = info.UserType; usersTable.Add(newUser); dbContext.SaveChanges(); if (info.UserType == "seeker") { SeekerProfile newSeekerProfile = new SeekerProfile(); newSeekerProfile.JinderUserId = newUser.JinderUserId; newSeekerProfile.Education = info.Education; newSeekerProfile.Experience = info.Experience; newSeekerProfile.Skills = info.Skills; newSeekerProfile.Certification = info.Certification; var seekersTable = dbContext.SeekerProfiles; seekersTable.Add(newSeekerProfile); dbContext.SaveChanges(); } message.StatusCode = HttpStatusCode.Created; return(message); }
public HttpResponseMessage PostNewPosterUser(PosterUserModel jinderPosterUser) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; var PosterTable = dbContext.JobPosts; HttpResponseMessage message = new HttpResponseMessage(); JinderUser jinderuser = (from user in usersTable where user.username == jinderPosterUser.username select user).FirstOrDefault <JinderUser>(); if (jinderuser != null) { message.StatusCode = HttpStatusCode.Conflict; return(message); } else { JinderUser user = new JinderUser(); user.FullName = jinderPosterUser.FullName; user.DateOfBirth = jinderPosterUser.DateOfBirth; user.Gender = jinderPosterUser.Gender; user.Address = jinderPosterUser.Address; user.UserType = jinderPosterUser.UserType; user.username = jinderPosterUser.username; user.password = jinderPosterUser.password; usersTable.Add(user); dbContext.SaveChanges(); JobPost posterUser = new JobPost(); posterUser.PosterId = user.JinderUserId; posterUser.Location = jinderPosterUser.Location; posterUser.JobDescription = jinderPosterUser.JobDescription; posterUser.RequiredSkills = jinderPosterUser.RequiredSkills; posterUser.SalaryRange = jinderPosterUser.SalaryRange; posterUser.OperationHours = jinderPosterUser.OperationHours; PosterTable.Add(posterUser); dbContext.SaveChanges(); message.StatusCode = HttpStatusCode.OK; return(message); } }
public IHttpActionResult DeleteJinderUser(int id) { JinderUser jinderUser = db.JinderUsers.Find(id); if (jinderUser == null) { return(NotFound()); } db.JinderUsers.Remove(jinderUser); db.SaveChanges(); return(Ok(jinderUser)); }
public HttpResponseMessage PostNewSeekerUser(SeekerUserModel jinderSeekerUser) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; var SeekersTable = dbContext.SeekerProfiles; HttpResponseMessage message = new HttpResponseMessage(); JinderUser jinderuser = (from user in usersTable where user.username == jinderSeekerUser.username select user).FirstOrDefault <JinderUser>(); if (jinderuser != null) { message.StatusCode = HttpStatusCode.Conflict; return(message); } else { JinderUser user = new JinderUser(); user.FullName = jinderSeekerUser.FullName; user.DateOfBirth = jinderSeekerUser.DateOfBirth; user.Gender = jinderSeekerUser.Gender; user.Address = jinderSeekerUser.Address; user.UserType = jinderSeekerUser.UserType; user.username = jinderSeekerUser.username; user.password = jinderSeekerUser.password; usersTable.Add(user); dbContext.SaveChanges(); SeekerProfile seekerUser = new SeekerProfile(); seekerUser.JinderUserId = user.JinderUserId; seekerUser.Certification = jinderSeekerUser.Certification; seekerUser.Education = jinderSeekerUser.Education; seekerUser.Experience = jinderSeekerUser.Experience; seekerUser.Skills = jinderSeekerUser.Skills; SeekersTable.Add(seekerUser); dbContext.SaveChanges(); message.StatusCode = HttpStatusCode.OK; return(message); } }
public HttpResponseMessage PostNewPosterUser(PosterUserModel jinderPosterUser) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; var PostersTable = dbContext.JobPosts; HttpResponseMessage message = new HttpResponseMessage(); //if(usersTable.Find(infoUser.JinderUserId) != null) //{ // message.StatusCode = HttpStatusCode.Conflict; // message.Content = new StringContent("Username: "******" is already registered"); // return message; //} JinderUser user = new JinderUser(); user.FullName = jinderPosterUser.FullName; user.DateOfBirth = jinderPosterUser.DateOfBirth; user.Gender = jinderPosterUser.Gender; user.Address = jinderPosterUser.Address; user.UserType = jinderPosterUser.UserType; user.username = jinderPosterUser.username; user.password = jinderPosterUser.password; usersTable.Add(user); dbContext.SaveChanges(); JobPost posterUser = new JobPost(); posterUser.JobPostId = user.JinderUserId; posterUser.JobDescription = jinderPosterUser.JobDescription; posterUser.RequiredSkills = jinderPosterUser.RequiredSkills; posterUser.SalaryRange = jinderPosterUser.SalaryRange; posterUser.OperationHours = jinderPosterUser.OperationHours; posterUser.Location = jinderPosterUser.Location; PostersTable.Add(posterUser); dbContext.SaveChanges(); //message.Content = new StringContent("name " + name); //message.Content = new StringContent("user saved"); return(message); }
public HttpResponseMessage PostNewSeekerUser(SeekerUserModel jinderSeekerUser) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; var SeekersTable = dbContext.SeekerProfiles; HttpResponseMessage message = new HttpResponseMessage(); //if(usersTable.Find(infoUser.JinderUserId) != null) //{ // message.StatusCode = HttpStatusCode.Conflict; // message.Content = new StringContent("Username: "******" is already registered"); // return message; //} JinderUser user = new JinderUser(); user.FullName = jinderSeekerUser.FullName; user.DateOfBirth = jinderSeekerUser.DateOfBirth; user.Gender = jinderSeekerUser.Gender; user.Address = jinderSeekerUser.Address; user.UserType = jinderSeekerUser.UserType; user.username = jinderSeekerUser.username; user.password = jinderSeekerUser.password; usersTable.Add(user); dbContext.SaveChanges(); SeekerProfile seekerUser = new SeekerProfile(); seekerUser.JinderUserId = user.JinderUserId; seekerUser.Certification = jinderSeekerUser.Certification; seekerUser.Education = jinderSeekerUser.Education; seekerUser.Experience = jinderSeekerUser.Experience; seekerUser.Skills = jinderSeekerUser.Skills; SeekersTable.Add(seekerUser); dbContext.SaveChanges(); //message.Content = new StringContent("name " + name); //message.Content = new StringContent("user saved"); return(message); }
public HttpResponseMessage PostSwipeAction(SwipeActionDTO swipeAction) { JinderDBEntities dbContext = new JinderDBEntities(); var actionsTable = dbContext.ExpressionLogs; var usersTable = dbContext.JinderUsers; HttpResponseMessage message = new HttpResponseMessage(); JinderUser sourcejinderuser = (from user in usersTable where user.JinderUserId == swipeAction.SourceUserId select user).FirstOrDefault <JinderUser>(); JinderUser targetjinderuser = (from user in usersTable where user.JinderUserId == swipeAction.TargetUserId select user).FirstOrDefault <JinderUser>(); if (swipeAction.SourceUserId == null || swipeAction.TargetUserId == null || swipeAction.IsInterested == null) { message.StatusCode = HttpStatusCode.BadRequest; return(message); } else if (sourcejinderuser == null || targetjinderuser == null) { message.StatusCode = HttpStatusCode.NotFound; return(message); } else { ExpressionLog action = new ExpressionLog(); action.IsInterested = swipeAction.IsInterested; action.SourceUserId = swipeAction.SourceUserId; action.TargetUserId = swipeAction.TargetUserId; actionsTable.Add(action); dbContext.SaveChanges(); message.StatusCode = HttpStatusCode.OK; return(message); } }
public HttpResponseMessage Post([FromBody] LoginInfo loginInfo) { JinderDBConnection db = new JinderDBConnection(); HttpResponseMessage message = new HttpResponseMessage(); // Try to get user JinderUser jinderUser = (from user in db.JinderUsers where user.Username == loginInfo.Username && user.Password == loginInfo.Password select user).FirstOrDefault(); if (jinderUser == null) { message.StatusCode = HttpStatusCode.BadRequest; return(message); } message.StatusCode = HttpStatusCode.OK; return(message); }
public static JinderSeeker getJinderSeeker(JinderUser user) { if (user.UserType != "seeker") { throw new Exception("Provided JinderUser: "******" is not a seeker!"); } JinderDBConnection dbContext = new JinderDBConnection(); SeekerProfile seekerProfile = (from profile in dbContext.SeekerProfiles where profile.JinderUserId == user.JinderUserId select profile).FirstOrDefault <SeekerProfile>(); if (seekerProfile == null) { throw new Exception("Could not find a SeekerProfile for JinderUser: " + user.Username); } JinderSeeker jinderSeeker = new JinderSeeker(); jinderSeeker.JinderUserId = user.JinderUserId; jinderSeeker.FullName = user.FullName; jinderSeeker.DateOfBirth = user.DateOfBirth; jinderSeeker.ProfilePicture = user.ProfilePicture; jinderSeeker.Gender = user.Gender; jinderSeeker.Address = user.Address; jinderSeeker.UserType = user.UserType; jinderSeeker.Password = user.Password; jinderSeeker.Username = user.Username; jinderSeeker.SeekerProfileId = seekerProfile.SeekerProfileId; jinderSeeker.Education = seekerProfile.Education; jinderSeeker.Experience = seekerProfile.Experience; jinderSeeker.Skills = seekerProfile.Skills; jinderSeeker.Certification = seekerProfile.Certification; return(jinderSeeker); }
public HttpResponseMessage Post([FromBody] SignupInfo info) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; JinderUser jinderUser = (from user in usersTable where user.Username == info.Username select user).FirstOrDefault <JinderUser>(); HttpResponseMessage message = new HttpResponseMessage(); if (jinderUser != null) { message.StatusCode = HttpStatusCode.Conflict; message.Content = new StringContent("Username: "******" is already registered."); return(message); } JinderUser newUser = new JinderUser(); newUser.Username = info.Username; newUser.Password = info.Password; newUser.FullName = info.Fullname; newUser.DateOfBirth = info.DateOfBirth; newUser.Gender = info.Gender; newUser.Address = info.Address; newUser.UserType = info.UserType; usersTable.Add(newUser); dbContext.SaveChanges(); message.StatusCode = HttpStatusCode.Created; return(message); }
public HttpResponseMessage PostLoginInfo(UserLogin userLogin) { JinderDBEntities dbContext = new JinderDBEntities(); var usersTable = dbContext.JinderUsers; HttpResponseMessage message = new HttpResponseMessage(); JinderUser jinderuser = (from user in usersTable where user.username == userLogin.username && user.password == userLogin.password select user).FirstOrDefault <JinderUser>(); if (jinderuser == null) { message.StatusCode = HttpStatusCode.NotFound; return(message); } else { message.StatusCode = HttpStatusCode.OK; return(message); } }