Example #1
0
        public JsonResult GetUpdates(string username)
        {
            if (!String.IsNullOrEmpty(username))
            {
                var dataContext = new Models.LinqModelHelperDataContext();
                var dbuser = from u in dataContext.Users
                             where u.Login == username
                             select u;
                Models.User user = dbuser.First();
                if (user.UserType == 1)
                {

                }
                else if (user.UserType == 2)
                {
                    var dbPinnedUsers = from rpu in dataContext.RecruiterPinnedUsers
                                        where rpu.UserID == user.UserID && (!rpu.LastScanTime.HasValue || ((DateTime)rpu.LastScanTime) < DateTime.UtcNow)
                                        select rpu;
                    if (dbPinnedUsers.Count() > 0)
                    {
                        Models.RecruiterPinnedUser pinneduser = dbPinnedUsers.First();
                        var jsonRet = new { HasUpdates = true, UserType = 2, JobID = pinneduser.JobID};
                        pinneduser.LastScanTime = DateTime.UtcNow;
                        dataContext.SubmitChanges();
                        return Json(jsonRet, JsonRequestBehavior.AllowGet);
                    }
                }
            }
            var jsonRet1 = new { HasUpdates = false };
            return Json(jsonRet1, JsonRequestBehavior.AllowGet);
        }
Example #2
0
 public Models.User GetUser(string username)
 {
     var dataContext = new Models.LinqModelHelperDataContext();
     var dbuser = from u in dataContext.Users
                  where u.Login == username
                  select u;
     Models.User user = dbuser.First();
     return user;
 }
 //
 // GET: /JobSeeker/
 public ActionResult Index(string username)
 {
     //String username = TempData["Username"] as String;
     ViewBag.Message = "Welcome to ASP.NET MVC!";
     var dataContext = new Models.LinqModelHelperDataContext();
     var dbuser = from u in dataContext.Users
                  where u.Login == username
                  select u;
     Models.User user = dbuser.First();
     Models.RecruiterJobSeeker.JobSeekerModel jsmodel = new Models.RecruiterJobSeeker.JobSeekerModel(user);
     return View(jsmodel);
 }
 public ActionResult ListFollowingRecruiters(string username)
 {
     ViewBag.Message = "Welcome to ASP.NET MVC!";
     var dataContext = new Models.LinqModelHelperDataContext();
     var dbuser = from u in dataContext.Users
                  where u.Login == username
                  select u;
     Models.User user = dbuser.First();
     Models.RecruiterJobSeeker.JobSeekerModel jsmodel = new Models.RecruiterJobSeeker.JobSeekerModel(user);
     TempData["UserID"] = user.UserID.ToString();
     return PartialView("_FollowingRecruiters", jsmodel);
 }
        public ActionResult PinUser(Guid recruiterID, Guid userID, Guid jobID)
        {
            var dataContext = new Models.LinqModelHelperDataContext();
            Models.RecruiterPinnedUser rpu = new Models.RecruiterPinnedUser();
            rpu.PinID = Guid.NewGuid();
            rpu.JobID = jobID;
            rpu.UserID = userID;
            rpu.RecruiterID = recruiterID;
            rpu.PinnedTime = DateTime.UtcNow;
            dataContext.RecruiterPinnedUsers.InsertOnSubmit(rpu);
            dataContext.SubmitChanges();

            var dbusers = from u in dataContext.Users
                          where u.UserID == recruiterID
                          select u;
            Models.User user = dbusers.First();
            return RedirectToAction("Index", "Recruiter1", new { username = user.Login });
        }
        public void ApplyJob(Guid jobID, Guid userID)
        {
            var dataContext = new Models.LinqModelHelperDataContext();
            //var dbuser = from u in dataContext.Users
            //             where u.Login == username
            //             select u;
            //Models.User user = (Models.User)dbuser.First();
            Models.UserAppliedJob uaj = new Models.UserAppliedJob();
            uaj.UserID = userID; // user.UserID;
            uaj.JobID = jobID;
            uaj.ID = Guid.NewGuid();
            uaj.AppliedTime = DateTime.UtcNow;

            // Find the "Submitted" column GUID
            var coldb = from c in dataContext.BoardColumns
                        where c.Name == "Submitted"
                        select c.ID;

            uaj.Stage = coldb.First();
            dataContext.UserAppliedJobs.InsertOnSubmit(uaj);
            dataContext.SubmitChanges();
        }
Example #7
0
        public Models.RecruiterJobSeeker.SearchResultModel PerformSearch(Models.User user, string keywords)
        {
            Models.RecruiterJobSeeker.SearchResultModel result = new Models.RecruiterJobSeeker.SearchResultModel(user, keywords);
            if (keywords != string.Empty)
            {
                if (user.UserType == 1)
                {
                    var dataContext = new Models.LinqModelHelperDataContext();
                    var dbusers = from u in dataContext.Users
                                 select u;

                    //result.Jobs.AddRange(dbjobs.Where(j => j.Description.ToUpper().Contains(keywords.ToUpper())));
                    foreach (Models.User u in dbusers)
                    {
                        //if (j.Description.ToUpper().Contains(keywords.ToUpper()) || j.Title.ToUpper().Contains(keywords.ToUpper()))
                        //{
                            result.Users.Add(u);
                        //}
                    }
                }
                else if (user.UserType == 2)
                {
                    var dataContext = new Models.LinqModelHelperDataContext();
                    var dbjobs = from j in dataContext.Jobs
                                 select j;

                    //result.Jobs.AddRange(dbjobs.Where(j => j.Description.ToUpper().Contains(keywords.ToUpper())));
                    foreach (Models.Job j in dbjobs)
                    {
                        if (j.Description.ToUpper().Contains(keywords.ToUpper()) || j.Title.ToUpper().Contains(keywords.ToUpper()))
                        {
                            result.Jobs.Add(j);
                        }
                    }
                }
            }
            return result;
        }
Example #8
0
        public Models.RecruiterJobSeeker.SearchResultModel PerformSearchForJob(Guid recruiterID, Guid jobID)
        {
            var dataContext = new Models.LinqModelHelperDataContext();
            var dbjobs = from j in dataContext.Jobs
                         where j.JobID == jobID
                         select j;
            Models.Job job = dbjobs.First();
            Models.RecruiterJobSeeker.SearchResultModel result = new Models.RecruiterJobSeeker.SearchResultModel(recruiterID, job, String.Empty);

            var dbusers = from u in dataContext.Users
                          select u;

            //result.Jobs.AddRange(dbjobs.Where(j => j.Description.ToUpper().Contains(keywords.ToUpper())));
            foreach (Models.User u in dbusers)
            {
                //if (j.Description.ToUpper().Contains(keywords.ToUpper()) || j.Title.ToUpper().Contains(keywords.ToUpper()))
                //{
                result.Users.Add(u);
                //}
            }
            return result;
        }
 public ActionResult ListPinnedJobs(string username)
 {
     var dataContext = new Models.LinqModelHelperDataContext();
     var dbuser = from u in dataContext.Users
                  where u.Login == username
                  select u;
     Models.User user = dbuser.First();
     Models.RecruiterJobSeeker.JobSeekerModel jsmodel = new Models.RecruiterJobSeeker.JobSeekerModel(user);
     TempData["UserID"] = user.UserID.ToString();
     return PartialView("_PinnedJobs", jsmodel);
 }
 public string SearchForm(string searchterm)
 {
     var dataContext = new Models.LinqModelHelperDataContext();
     string username = Request.Form["username"];
     var dbuser = from u in dataContext.Users
                 where u.Login == username
                 select u;
     Models.User user = dbuser.First();
     Models.RecruiterJobSeeker.SearchResultModel searchResult = UserHelper.Instance.PerformSearch(user, Request.Form["searchterm"]);
     return UserHelper.Instance.RenderPartialViewToString(this.ControllerContext, "_JobSeekerSearchResult", this.ViewData, this.TempData, searchResult);
 }
        public RecruiterModel(User u)
        {
            this.User = u;
            JobModel = new List<JobUserSkillModel>();
            SearchResult = new SearchResultModel(u, string.Empty);
            this.ClientUserGroup = new List<ClientUserGroupModel>();
            StagedUsers = new List<List<Models.User>>();

            var dataContext = new Models.LinqModelHelperDataContext();
            Board = u.RecruiterBoards[0]; // each user has only one board?
            //var dbresult = from c in dataContext.Users
            //               join j in dataContext.Jobs on c.UserID equals j.ClientID
            //               join aj in dataContext.UserAppliedJobs on j.JobID equals aj.JobID
            //               join c1 in dataContext.Users on aj.UserID equals c1.UserID
            //               where j.UserID == u.UserID
            //               select new {c, j, c1};

            //dbresult.GroupBy( r => new { r.c.UserID, r.j.JobID} );

            Columns = new List<string>();
            //Columns.Add("Client");
            //Columns.Add("Position");
            //Columns.Add("Submitted");
            var dbcolumns = from col in dataContext.BoardColumns
                            where col.BoardID == Board.BoardID
                            orderby col.ColumnIndex
                            select col;

            int cindex = 0;
            foreach (var column in dbcolumns)
            {
                Columns.Add(column.Name);
                cindex++;
                //StagedUsers[column.ColumnIndex] = new List<Models.User>();

                //// Retrieve all the applicants at this stage for this job
                //var dbusers = from u1 in dataContext.Users
                //              join u2 in dataContext.UserAppliedJobs on u1.UserID equals u2.UserID
                //              where u2.Stage == column.ID
                //              select u1;
                //StagedUsers[column.ColumnIndex].AddRange(dbusers);
            }

            // select all the rows and cells of a Job Board
            var dbboardcontents = from row in dataContext.JobBoardRows
                                  join cell in dataContext.BoardContents on row.RowID equals cell.RowID into grow
                                  orderby row.RowIndex
                                  where row.BoardID == Board.BoardID
                                  select new { row = grow };

            this.BoardContents = new List<BoardRow>();
            BoardRow rowcontents = null;
            foreach (var result in dbboardcontents)
            {
                //ClientUserGroupModel cug = new ClientUserGroupModel(this.Board, i++, cindex, result.c, result.j, result.c1);
                //this.ClientUserGroup.Add(cug);
                var orderedcolumns = result.row.OrderBy(c => c.ColumnIndex);
                foreach (var cell in orderedcolumns)
                {
                    if (rowcontents == null)
                        rowcontents = new BoardRow(cell.JobBoardRow.RowIndex, cell.JobBoardRow.RowID.ToString(), cell.JobBoardRow.Job, cell.JobBoardRow.User);
                    if (String.IsNullOrEmpty(cell.Value))
                        rowcontents.AddContent(cell.ColumnIndex, cell.CellID.ToString(), "");
                    else
                        rowcontents.AddContent(cell.ColumnIndex, cell.CellID.ToString(), cell.Value);
                }
                this.BoardContents.Add(rowcontents);
                rowcontents = null;
            }

            //foreach (Job j in u.Jobs)
            //{
            //    JobUserSkillModel jsm = new JobUserSkillModel(u, j);
            //    JobModel.Add(jsm);
            //}
        }
        public JobUserSkillModel(User u, Job j)
        {
            User = u;
            Job = j;
            Skills = new List<JobSkill>();
            AdditionalSkill = new JobSkill();
            AppliedUsers = new List<Models.User>();
            PinnedUsers = new List<User>();
            var dataContext = new Models.LinqModelHelperDataContext();

            var dbskills = from s in dataContext.JobSkills
                           where s.JobID == j.JobID
                           select s;

            foreach (var s in dbskills)
            {
                Skills.Add(s);
            }

            GetAppliedUsers(dataContext);
            //GetPinnedUsers(dataContext);
        }
        public JobSeekerModel(User u)
        {
            if (u != null)
            {
                this.User = u;
                this.SearchResult = new SearchResultModel(u, string.Empty);
                this.AppliedJobs = new List<JobUserSkillModel>();
                this.PinnedJobs = new List<JobUserSkillModel>();
                this.FollowingRecruiters = new List<Models.User>();
                var dataContext = new Models.LinqModelHelperDataContext();

                GetAppliedJobs(dataContext);
                GetPinnedJobs(dataContext);
                GetFollowingRecruiters(dataContext);
            }
        }
        public ClientUserGroupModel(Models.RecruiterBoard board, int rowindex, int columns, Models.User client, Models.Job job, Models.User applicant)
        {
            this.Client = client;
            this.Job = job;
            this.Applicant = applicant;
            this.RowIndex = rowindex;
            this.Columns = columns;
            var dataContext = new Models.LinqModelHelperDataContext();
            var dbresult = from aj in dataContext.UserAppliedJobs
                           join col in dataContext.BoardColumns on aj.Stage equals col.ID
                           where aj.UserID == applicant.UserID && aj.JobID == job.JobID
                           select col;
            this.Column = (Models.BoardColumn)dbresult.First();

            this.ColumnIndexBitmap = new bool[columns - 2];  // ignore the client name and position name columns
            for (int i = 0; i < columns - 2; i++)
                ColumnIndexBitmap[i] = false;

            var dbcolumns = from col in dataContext.BoardColumns
                            where col.BoardID == board.BoardID
                            orderby col.ColumnIndex
                            select col;
            int cindex = 0;
            foreach (var col in dbcolumns)
            {
                if (this.Column.ID == col.ID)
                {
                    ColumnIndexBitmap[cindex] = true;
                    this.ColumnIndex = cindex;
                    break;
                }
                cindex++;
            }
        }
        public void SaveBoard(string boardID, List<BoardData> board)
        {
            if (board != null)
            {
                var dataContext = new Models.LinqModelHelperDataContext();
                var dbboardOwnerID = from b in dataContext.RecruiterBoards
                                     where b.BoardID.ToString() == boardID
                                     select b;
                string boardOwnerID = dbboardOwnerID.First().OwnerID.ToString();

                // First set all the applied jobs with the columns to null
                //var dbappliedjobs = from aj in dataContext.UserAppliedJobs
                //                    join bc in dataContext.BoardColumns on aj.Stage equals bc.BoardID
                //                    select aj;

                //foreach (Models.UserAppliedJob aj in dbappliedjobs)
                //{
                //    aj.Stage = Guid.Empty;
                //}

                // Then delete all columns of the particular board
                var bcolumns = dataContext.BoardColumns.Where(c => c.BoardID.ToString() == boardID);
                dataContext.BoardColumns.DeleteAllOnSubmit(bcolumns);

                ArrayList columnIDs = new ArrayList();
                var boardcolumns = from r in board
                                   where r.row == 0
                                   orderby r.col
                                   select r;
                // Save columns
                foreach (BoardData bdata in boardcolumns)
                {
                    Models.BoardColumn boardColumn = new Models.BoardColumn();
                    boardColumn.BoardID = new Guid(boardID);
                    boardColumn.ColumnIndex = bdata.col;
                    boardColumn.ID = Guid.NewGuid();
                    boardColumn.Name = bdata.value;
                    dataContext.BoardColumns.InsertOnSubmit(boardColumn);
                    columnIDs.Add(boardColumn.BoardID);
                }

                // Now remove all values of a board
                ArrayList clientIDs = new ArrayList();
                ArrayList jobIDs = new ArrayList();
                int rowindex = -1;
                var boardelements = from r in board
                                    where r.row > 0
                                    select r;
                boardelements.OrderBy(r => new { r.col }).GroupBy(r => new { r.row });
                bool isRowUpdate = true;
                Guid currClientID = Guid.Empty;
                Guid currJobID = Guid.Empty;
                Guid currRowID = Guid.Empty;
                Models.User newclient = null;
                bool waitForJob = false;
                foreach (BoardData cell in boardelements)
                {
                    if (cell.row != rowindex)
                    {
                        // The first column of the row contains the rowid
                        isRowUpdate = String.IsNullOrEmpty(cell.rowid) ? false : true;
                        // Save the row
                        if (isRowUpdate)
                        {
                            // Find the row
                            var dbrow = from row in dataContext.JobBoardRows
                                        where row.RowID.ToString() == cell.rowid
                                        select row;
                            Models.JobBoardRow boardrow = dbrow.First();
                            boardrow.RowIndex = cell.row;
                            currRowID = boardrow.RowID;

                            waitForJob = false;
                        }
                        // TODO: what if the user adds a new row?
                        // TODO: we might want to ask the user to select from a client/position
                        // TODO: user should not be allowed to type arbitrarily in the new row
                        else
                        {
                            // TODO search for a user
                            newclient = new Models.User();
                            newclient.UserID = Guid.NewGuid();
                            newclient.FirstName = newclient.LastName = newclient.Login = cell.value;
                            dataContext.Users.InsertOnSubmit(newclient);

                            // Next cell should be the position info
                            waitForJob = true;
                        }
                        rowindex = cell.row;
                    }

                    else if (waitForJob)
                    {
                        Models.Job newjob = new Models.Job();
                        newjob.JobID = Guid.NewGuid();
                        newjob.ClientID = newclient.UserID;
                        newjob.Title = cell.value;
                        newjob.PostDate = DateTime.UtcNow;
                        newjob.UserID = new Guid(boardOwnerID);
                        dataContext.Jobs.InsertOnSubmit(newjob);

                        Models.JobBoardRow newrow = new Models.JobBoardRow();
                        newrow.RowID = Guid.NewGuid();
                        newrow.RowIndex = cell.row;
                        newrow.ClientID = newclient.UserID;
                        newrow.BoardID = new Guid(boardID);
                        newrow.JobID = newjob.JobID;
                        dataContext.JobBoardRows.InsertOnSubmit(newrow);
                        currRowID = newrow.RowID;
                        currJobID = newjob.JobID;

                        Models.BoardContent bc = new Models.BoardContent();
                        bc.RowID = currRowID;
                        bc.ColumnIndex = 0;
                        bc.CellID = Guid.NewGuid();
                        bc.Value = newclient.FirstName;
                        dataContext.BoardContents.InsertOnSubmit(bc);

                        Models.BoardContent bc1 = new Models.BoardContent();
                        bc1.RowID = currRowID;
                        bc1.ColumnIndex = 1;
                        bc1.CellID = Guid.NewGuid();
                        bc1.Value = newjob.Title;
                        dataContext.BoardContents.InsertOnSubmit(bc1);
                        waitForJob = false;
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(cell.value))
                            cell.value = "";
                        else
                        {
                            cell.value = cell.value.Replace("\n", "");
                            cell.value = cell.value.Trim();
                        }
                        if (!String.IsNullOrEmpty(cell.cellid))
                        {
                            // Existing cell, update it
                            string[] fields = cell.cellid.Split('_');
                            if (fields != null)
                            {
                                var dbcell = from c in dataContext.BoardContents
                                                where c.CellID.ToString() == cell.cellid
                                                select c;
                                Models.BoardContent bc = dbcell.First();
                                bc.ColumnIndex = cell.col;
                                bc.RowID = currRowID;
                                bc.Value = cell.value;
                            }

                            /*if (fields[0].Equals("Client", StringComparison.OrdinalIgnoreCase))
                            {
                                // The ID of this cell indicates the client ID
                                if (isUpdate)
                                {
                                    var client = from u in dataContext.Users
                                                    where u.UserID.ToString() == fields[2]
                                                    select u;
                                    Models.User user = client.First();
                                    user.FirstName = cell.value;
                                    user.LastName = cell.value;
                                    currClientID = user.UserID;
                                }
                                else
                                {
                                    Models.User user = new Models.User();
                                    user.UserID = Guid.NewGuid();
                                    user.FirstName = user.LastName = cell.value;
                                    dataContext.Users.InsertOnSubmit(user);
                                    currClientID = user.UserID;
                                }
                            }
                            else if (fields[0].Equals("Job", StringComparison.OrdinalIgnoreCase))
                            {
                                // The ID of this cell indicates the Job ID
                                if (isUpdate)
                                {
                                    var dbposition = from j in dataContext.Jobs
                                                        where j.JobID.ToString() == fields[2]
                                                        select j;
                                    Models.Job job = dbposition.First();
                                    job.Title = cell.value;
                                    currJobID = job.JobID;
                                }
                                else
                                {
                                    Models.Job job = new Models.Job();
                                    job.JobID = Guid.NewGuid();
                                    currJobID = job.JobID;
                                    job.Title = cell.value;
                                    job.PostDate = DateTime.UtcNow;
                                    job.UserID = new Guid(boardOwnerID);
                                    dataContext.Jobs.InsertOnSubmit(job);
                                }
                            } */
                        }
                        else
                        {
                            Models.BoardContent bc = new Models.BoardContent();
                            bc.RowID = currRowID;
                            bc.CellID = Guid.NewGuid();
                            bc.ColumnIndex = cell.col;
                            bc.Value = cell.value;
                            dataContext.BoardContents.InsertOnSubmit(bc);
                        }

                            //else
                            //{
                            //    // These cells are applicants
                            //    Guid columnID = (Guid)columnIDs[cell.col];
                            //    if (isUpdate)
                            //    {
                            //        var dbapj = from j in dataContext.UserAppliedJobs
                            //                where j.JobID == currJobID
                            //                select j;

                            //    }
                            //    else
                            //    {
                            //        Models.UserAppliedJob uaj = new Models.UserAppliedJob();
                            //    }
                            //}
                    }

                }
                dataContext.SubmitChanges();
            }
        }
 public ActionResult PostNewJob()
 {
     var dataContext = new Models.LinqModelHelperDataContext();
     Models.Job j = new Models.Job();
     j.JobID = Guid.NewGuid();
     j.Employer = Request.Form["Employer"];
     j.Description = Request.Form["Description"];
     j.Title = Request.Form["Title"];
     j.UserID = new Guid(Request.Form["UserID"]);
     j.PostDate = DateTime.Now;
     j.Status = 1;
     dataContext.Jobs.InsertOnSubmit(j);
     dataContext.SubmitChanges();
     for (int i = 1; i <= Int32.Parse(Request.Form["skillIndex"]); i++)
     {
         string skill = Request.Form["Skill" + i.ToString()];
         string year = Request.Form["Year" + i.ToString()];
         if (skill != String.Empty && year != string.Empty)
         {
             Models.JobSkill jobskill = new Models.JobSkill();
             jobskill.JobSkillID = Guid.NewGuid();
             jobskill.JobID = j.JobID;
             jobskill.Skill = skill;
             jobskill.Year = (short)Int32.Parse(year);
             dataContext.JobSkills.InsertOnSubmit(jobskill);
         }
     }
     dataContext.SubmitChanges();
     TempData["Username"] = Request.Form["username"];
     return RedirectToAction("Index", "Recruiter1", new { username = Request.Form["username"] });
 }