//Add candidate feedback for position
        public void addcandidatefeedbackposition(candidatefeedback CF)
        {
            using (RecrutmentsysEntities db = new RecrutmentsysEntities())
            {
                CANDIDATE_POSITION          cp  = db.CANDIDATE_POSITION.Where(o => o.CandidateCode == CF.candidatecode).FirstOrDefault();
                CANDIDATE_FEEDBACK_POSITION cfp = new CANDIDATE_FEEDBACK_POSITION();
                cfp.CandidateCode     = cp.CandidateCode;
                cfp.CandidateEmail    = cp.CandidateEmail;
                cfp.Candidate_Yof_exp = cp.Candidate_Yof_exp;
                cfp.CompanyId         = cp.CompanyId;
                cfp.DepartmentCode    = cp.DepartmentCode;

                COMPANY_JOB_OPENING cjo = db.COMPANY_JOB_OPENING.Where(o => o.DepartmentCode == cp.DepartmentCode).FirstOrDefault();
                cfp.DepartmentName           = cjo.DepartmentName;
                cfp.RequestedBy              = cjo.RequestedBy;
                cfp.HrId                     = cjo.HrId;
                cfp.HrEmail                  = cjo.HrEmail;
                cfp.Name_of_Vacancy          = cjo.Name_of_Vacancy;
                cfp.Number_of_Position       = cjo.Number_of_Position;
                cfp.Required_Technical_Skill = cjo.Required_Technical_Skill;
                cfp.Special_Technical_Skill  = cjo.Special_Technical_Skill;
                cfp.Min_Yearof_Experience    = cjo.Min_Yearof_Experience;
                cfp.Min_Qualification        = cjo.Min_Qualification;
                cfp.Deadline_Date            = cjo.Deadline_Date;
                cfp.Requested_Date           = cjo.Requested_Date;
                cfp.RoundingPercentage       = CF.rounding_percent;
                cfp.OfferLatter              = "No";
                cfp.Feedbackprocess          = false;

                db.CANDIDATE_FEEDBACK_POSITION.Add(cfp);
                db.SaveChanges();

                Round_Detail_feedback rdf = new Round_Detail_feedback();
                rdf.CompanyId      = cfp.CompanyId;
                rdf.CandidateCode  = cfp.CandidateCode;
                rdf.DepartmentCode = cfp.DepartmentCode;
                rdf.HrId           = cfp.HrId;
                rdf.RoundOne       = CF.round1;
                rdf.RoundOne_per   = CF.round1P;
                rdf.RoundTwo       = CF.round2;
                rdf.RoundTwo_per   = CF.round2P;
                rdf.RoundThree     = CF.round3;
                rdf.RoundThree_per = CF.round3P;
                rdf.totalround_per = CF.rounding_percent;

                db.Round_Detail_feedback.Add(rdf);
                db.SaveChanges();

                CANDIDATE_POSITION canp = db.CANDIDATE_POSITION.Find(cp.CandidateId);
                canp.ISActive = false;
                db.SaveChanges();
            }
        }
        public ActionResult AddCandidateFeedback()
        {
            string loginname         = HttpContext.User.Identity.Name;
            RecrutmentsysEntities db = new RecrutmentsysEntities();
            var id   = db.COMPANY_HR_REGISTER.Where(o => o.HrEmail == loginname);
            int hrid = id.FirstOrDefault().HrId;

            List <CANDIDATE_POSITION> CNP = (from data in db.CANDIDATE_POSITION
                                             where data.HrId == hrid && data.ISActive == true
                                             select data).ToList();
            CANDIDATE_POSITION CANP = new CANDIDATE_POSITION();

            CANP.CandidateCode = "Select";
            CNP.Insert(0, CANP);
            SelectList        Obj            = new SelectList(CNP, "CandidateCode", "CandidateCode", 0);
            candidatefeedback addcanfeedback = new candidatefeedback();

            addcanfeedback.candicode = Obj;

            return(View(addcanfeedback));
        }
        public ActionResult AddCandidateFeedback(candidatefeedback cfb)
        {
            //string loginname = HttpContext.User.Identity.Name;
            //RecrutmentsysEntities db = new RecrutmentsysEntities();
            //var id = db.COMPANY_HR_REGISTER.Where(o => o.HrEmail == loginname);
            //int hrid = id.FirstOrDefault().HrId;

            //List<CANDIDATE_POSITION> CNP = (from data in db.CANDIDATE_POSITION
            //                                where data.HrId == hrid && data.ISActive == true
            //                                select data).ToList();
            //CANDIDATE_POSITION CANP = new CANDIDATE_POSITION();
            //CANP.CandidateCode = "Select";
            //CNP.Insert(0, CANP);
            //SelectList Obj = new SelectList(CNP, "CandidateCode", "CandidateCode", 0);
            feedbackselect();
            candidatefeedback addcanfeedback = new candidatefeedback();

            addcanfeedback.candicode = ViewBag.obj;
            if (ModelState.IsValid)
            {
                if (cfb.candidatecode == "Select")
                {
                    ModelState.AddModelError("", "Please select First");
                    return(View(addcanfeedback));
                }
                else
                {
                    UserManager UM = new UserManager();
                    UM.addcandidatefeedbackposition(cfb);
                    ModelState.Clear();
                    TempData["msg"] = "Insert successfully";
                    feedbackselect();
                    addcanfeedback.candicode = ViewBag.obj;
                }
            }

            return(View(addcanfeedback));
        }
        public List <candidatefeedback> getoffer(string Loginname)
        {
            List <candidatefeedback> offerforcandi = new List <candidatefeedback>();

            using (RecrutmentsysEntities db = new RecrutmentsysEntities())
            {
                var id        = db.COMPANY_REGISTER_REFRENCES.Where(o => o.CompanyEmailRef == Loginname);
                int compid    = Convert.ToInt32(id.FirstOrDefault().CompanyId);
                var listusers = (from cjo in db.CANDIDATE_FEEDBACK_POSITION
                                 join rdf in db.Round_Detail_feedback on cjo.CandidateCode equals rdf.CandidateCode
                                 where cjo.CompanyId == compid
                                 select new
                {
                    cjo.CandidateCode,
                    cjo.DepartmentCode,
                    cjo.CandidateEmail,
                    cjo.Candidate_Yof_exp,
                    cjo.DepartmentName,
                    cjo.Name_of_Vacancy,
                    cjo.Number_of_Position,
                    cjo.Required_Technical_Skill,
                    cjo.Special_Technical_Skill,
                    cjo.Min_Qualification,
                    cjo.Min_Yearof_Experience,
                    cjo.Deadline_Date,
                    rdf.RoundOne,
                    rdf.RoundOne_per,
                    rdf.RoundTwo,
                    rdf.RoundTwo_per,
                    rdf.RoundThree,
                    rdf.RoundThree_per,
                    rdf.totalround_per
                }).ToList();
                if (listusers != null)
                {
                    candidatefeedback cf;
                    foreach (var i in listusers)
                    {
                        cf = new candidatefeedback();
                        cf.candidatecode     = i.CandidateCode;
                        cf.candidateemail    = i.CandidateEmail;
                        cf.yerofexperience   = Convert.ToString(i.Candidate_Yof_exp);
                        cf.Depetcode         = i.DepartmentCode;
                        cf.Departmentname    = i.DepartmentName;
                        cf.nameofvacancy     = i.Name_of_Vacancy;
                        cf.numberofpostion   = i.Number_of_Position;
                        cf.reqtechnicalskill = i.Required_Technical_Skill;
                        cf.specialskill      = i.Special_Technical_Skill;
                        cf.minyerofexp       = Convert.ToString(i.Min_Yearof_Experience);
                        cf.minqualifi        = i.Min_Qualification;
                        cf.deadlinedate      = Convert.ToString(i.Deadline_Date);
                        cf.round1            = i.RoundOne;
                        cf.round1P           = Convert.ToInt32(i.RoundOne_per);
                        cf.round2            = i.RoundTwo;
                        cf.round2P           = Convert.ToInt32(i.RoundTwo_per);
                        cf.round3            = i.RoundThree;
                        cf.round3P           = Convert.ToInt32(i.RoundThree_per);
                        cf.rounding_percent  = Convert.ToInt32(i.totalround_per);
                        offerforcandi.Add(cf);
                    }
                }
            }
            return(offerforcandi);
        }