public ActionResult _ExpFormView(string id)
        {
            jpuser SessionUser = GetSessionUser();

            if (!string.IsNullOrEmpty(id))
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpexperience != null)
                        {
                            jpexperience obj = SessionUser.objjpprofile.lstjpexperience.Find(q => q.EXPID == int.Parse(id) && q.PROFILEID.Equals(SessionUser.objjpprofile.PROFILEID));
                            if (obj != null)
                            {
                                return(PartialView(obj));
                            }
                        }
                    }
                }
            }
            return(PartialView(new jpexperience()
            {
                isNewRecord = Shared.Constants.STR_YES
            }));
        }
Example #2
0
        // Mark: This method decode and returns Json Web Token
        public static object decodeJWT(string token)
        {
            try
            {
                IJsonSerializer   serializer = new JsonNetSerializer();
                IDateTimeProvider provider   = new UtcDateTimeProvider();
                IJwtValidator     validator  = new JwtValidator(serializer, provider);
                IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
                IJwtDecoder       decoder    = new JwtDecoder(serializer, validator, urlEncoder);

                var json = decoder.Decode(token, ConfigurationManager.AppSettings[Constants.ASK_JWT_KEY], verify: true);
                Console.WriteLine(json);
                jpuser payload = JsonConvert.DeserializeObject <jpuser>(Convert.ToString(json));
                return(payload);
            }
            catch (TokenExpiredException)
            {
                //ErrorResponse error = new ErrorResponse(StringConstants.Message.TokenExpired, HttpStatusCode.BadRequest);
                return(Constants.MSG_ERROR);
            }
            catch (SignatureVerificationException)
            {
                //ErrorResponse error = new ErrorResponse(StringConstants.Message.TokenInvalidSignature, HttpStatusCode.BadRequest);
                return(Constants.MSG_ERROR);
            }
        }
        public ActionResult Verify(string token)
        {
            if (!string.IsNullOrEmpty(token))
            {
                object jsonJWT = Shared.Utility.decodeJWT(token);
                if (jsonJWT.GetType() == typeof(jpuser))
                {
                    jpuser        obj = (jpuser)jsonJWT;
                    List <jpuser> lst = jpuserManager.Getjpuser("USERID = '" + obj.USERID + "'");
                    if (lst.Count > 0)
                    {
                        if (!lst[Shared.Constants.ZERO].ACTIVE.Equals(Shared.Constants.STR_YES))
                        {
                            obj.ACTIVE = Shared.Constants.STR_YES;
                            string ret = jpuserManager.Savejpuser(obj);
                            if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                            {
                                obj.objjpprofile = GetCompleteUserProfile(obj.USERID);
                                SetSessionUser(obj);
                                return(RedirectToAction("Index"));
                            }
                        }
                        return(RedirectToAction("Index"));
                    }
                }
            }

            return(RedirectToAction("Error"));
        }
        public string Signin(jpuser model)
        {
            string        ret       = Shared.Constants.MSG_ERR_NOUSEREXIST.Text;
            List <jpuser> lstjpUSER = jpuserManager.Getjpuser(" EMAIL = '" + model.EMAIL + "'", null); //and PASSWORD = '******'

            if (lstjpUSER.Count > 0)
            {
                if (lstjpUSER.First().PASSWORD.Equals(model.PASSWORD))
                {
                    lstjpUSER.First().objjpprofile = GetCompleteUserProfile(lstjpUSER.First().USERID);
                    if (lstjpUSER.First().objjpprofile != null)
                    {
                        lstjpUSER.First().isProfileComplete = isProfileComplete(lstjpUSER.First().objjpprofile);
                        SetSessionUser(lstjpUSER.First());

                        ret = Shared.Constants.MSG_SUCCESS.Text;
                    }
                    else
                    {
                        ret = Shared.Constants.MSG_ERROR.Text;
                    }
                }
                else
                {
                    ret = Shared.Constants.MSG_ERR_INVALIDCRED.Text;
                }
            }

            return(ret);
        }
        public string ApplyJobCV(FormCollection fc)
        {
            //string Name = Request.Form[1];
            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file        = Request.Files[0];
                byte[]             fileInBytes = new byte[file.ContentLength];
                using (BinaryReader theReader = new BinaryReader(file.InputStream))
                {
                    fileInBytes = theReader.ReadBytes(file.ContentLength);
                }
                string fileAsString = Convert.ToBase64String(fileInBytes);

                jpuser SessionUser = GetSessionUser();
                SessionUser.objjpprofile.LONGCV = fileAsString;
                string ret = jpprofileManager.Savejpprofile(SessionUser.objjpprofile);

                if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                {
                    string id     = fc["id"].ToString();
                    string expsal = fc["expsal"].ToString();
                    if (ApplyJob(id, expsal).Equals(Shared.Constants.MSG_SUCCESS.Text))
                    {
                        return(Shared.Constants.MSG_SUCCESS.Text);
                    }
                }
            }

            return(Shared.Constants.MSG_ERROR.Text);
        }
        public string _ExpFormView(jpexperience model)
        {
            jpuser SessionUser = GetSessionUser();

            if (model != null)
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpexperience != null)
                        {
                            model.PROFILEID = SessionUser.objjpprofile.PROFILEID;
                            if (model.EXPID == 0)
                            {
                                model.EXPID = GetTempID(SessionUser.objjpprofile.lstjpexperience);
                            }
                            else
                            {
                                jpexperience obj = SessionUser.objjpprofile.lstjpexperience.Find(a => a.EXPID == model.EXPID);
                                if (obj != null)
                                {
                                    SessionUser.objjpprofile.lstjpexperience.Remove(obj);
                                }
                            }
                            SessionUser.objjpprofile.lstjpexperience.Add(model);
                            return(Shared.Constants.MSG_SUCCESS.Text);
                        }
                    }
                }
            }
            return(Shared.Constants.MSG_ERROR.Text);
        }
        public string _EduFormView(jpqualification model)
        {
            jpuser SessionUser = GetSessionUser();

            if (model != null)
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpqualification != null)
                        {
                            model.PROFILEID = SessionUser.objjpprofile.PROFILEID;
                            if (model.QUALIFICATIONID == 0)
                            {
                                model.QUALIFICATIONID = GetTempID(SessionUser.objjpprofile.lstjpqualification);
                            }
                            else
                            {
                                jpqualification obj = SessionUser.objjpprofile.lstjpqualification.Find(a => a.QUALIFICATIONID == model.QUALIFICATIONID);
                                if (obj != null)
                                {
                                    SessionUser.objjpprofile.lstjpqualification.Remove(obj);
                                }
                            }
                            SessionUser.objjpprofile.lstjpqualification.Add(model);
                            return(Shared.Constants.MSG_SUCCESS.Text);
                        }
                    }
                }
            }
            return(Shared.Constants.MSG_ERROR.Text);
        }
        public ActionResult _EduFormView(string id)
        {
            jpuser SessionUser = GetSessionUser();

            if (!string.IsNullOrEmpty(id))
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpqualification != null)
                        {
                            jpqualification obj = SessionUser.objjpprofile.lstjpqualification.Find(q => q.QUALIFICATIONID == int.Parse(id) && q.PROFILEID.Equals(SessionUser.objjpprofile.PROFILEID));
                            if (obj != null)
                            {
                                return(PartialView(obj));
                            }
                        }
                    }
                }
            }
            return(PartialView(new jpqualification()
            {
                isNewRecord = Shared.Constants.STR_YES
            }));
        }
        public ActionResult _AppliedJobs()
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile != null)
                {
                    List <jpopeningapplication> lstjpopeningapplication = jpopeningapplicationManager.Getjpopeningapplication("PROFILEID = '" + SessionUser.objjpprofile.PROFILEID + "'");
                    if (lstjpopeningapplication.Count > 0)
                    {
                        string           joined       = string.Join(",", lstjpopeningapplication.Select(x => x.OPENINGID));
                        List <jpopening> lstjpopening = jpopeningManager.Getjpopening("OPENINGID in (" + joined + ")");
                    }

                    //ExpectedSalary

                    /*
                     * if (SessionUser.objjpprofile.lstjpexperience != null)
                     * {
                     *  return PartialView(SessionUser.objjpprofile.lstjpexperience);
                     * }
                     */
                }
            }
            return(PartialView());
        }
        public string Signup(VMSignUp model)
        {
            List <jpuser> lstjpUSER = jpuserManager.Getjpuser(" USERNAME = '******'", null);

            if (lstjpUSER.Count > 0)
            {
                return("Username already Exists");
            }

            lstjpUSER = jpuserManager.Getjpuser(" EMAIL = '" + model.Email + "'", null);
            if (lstjpUSER.Count > 0)
            {
                return("An account already exists with the given Email");
            }

            jpuser userobj = new jpuser();

            userobj.EMAIL    = model.Email;
            userobj.PASSWORD = model.Password;
            userobj.USERNAME = model.Username;
            userobj.ACTIVE   = "N";

            jpprofile profileobj = new jpprofile();

            profileobj.NAME          = " ";
            profileobj.ADDRESS       = " ";
            profileobj.CONTACT       = model.Contact;
            profileobj.DOB           = DateTime.ParseExact(model.DOB, Shared.Constants.DATE_RFC_FORMAT, CultureInfo.InvariantCulture);
            profileobj.GENDER        = model.Gender;
            profileobj.CURRENTSALARY = "0";

            MySqlConnection conn = Shared.BaseManager.PrimaryConnection();

            conn.Open();
            var    transaction = conn.BeginTransaction();
            string ret         = jpuserManager.Savejpuser(userobj, conn, transaction);

            if (!ret.Equals(Shared.Constants.MSG_ERR_DBSAVE.Text))
            {
                profileobj.USERID = int.Parse(ret);
                ret = jpprofileManager.Savejpprofile(profileobj, conn, transaction);
                if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                {
                    transaction.Commit();
                    conn.Close();
                    conn.Dispose();
                    //add verification url code here
                    userobj.USERID = profileobj.USERID;
                    string _token = (string)getVerificationURL(userobj);

                    return(sendEmail(userobj.EMAIL, _token));
                }
            }

            transaction.Rollback();
            conn.Close();
            conn.Dispose();
            return(Shared.Constants.MSG_ERR_SERVER.Text);
        }
 public string ReSendVerfLink()
 {
     if (GetSessionUser() != null)
     {
         jpuser obj = GetSessionUser();
         string ret = sendEmail(obj.EMAIL, (string)getVerificationURL(obj));
         if (ret.Equals(Shared.Constants.MSG_SUCCESS.Text))
         {
             obj.isVerifyLinkSent = true;
             SetSessionUser(obj);
         }
         return(ret);
     }
     return(Shared.Constants.MSG_SESSION_USER_EMPTY.Text);
 }
        public ActionResult JobsApplied()
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile != null)
                {
                    List <jpopening> lstjpopeningapplications = jpopeningManager.GetjpopeningApplicationDetail(SessionUser.objjpprofile.PROFILEID.ToString());
                    return(PartialView(lstjpopeningapplications));
                }
            }

            //List<jpopening> lstjpopeningapplications = jpopeningManager.Getjpopening("PROFILEID='" + id + "'");

            return(PartialView());
        }
        public ActionResult _ExpTabView()
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile != null)
                {
                    if (SessionUser.objjpprofile.lstjpexperience != null)
                    {
                        return(PartialView(SessionUser.objjpprofile.lstjpexperience));
                    }
                }
            }

            return(PartialView(new List <jpexperience>()));
        }
        public ActionResult _EduTabView()
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile != null)
                {
                    if (SessionUser.objjpprofile.lstjpqualification != null)
                    {
                        return(PartialView(SessionUser.objjpprofile.lstjpqualification));
                    }
                }
            }

            return(PartialView(new List <jpqualification>()));
        }
        public ActionResult ViewApplicationmultiple()
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile == null)
                {
                    SessionUser.objjpprofile = GetCompleteUserProfile(SessionUser.USERID);
                    SetSessionUser(SessionUser);
                    return(View(SessionUser.objjpprofile));
                }
                else
                {
                    return(View(SessionUser.objjpprofile));
                }
            }
            return(View(new jpprofile()));
        }
        public string ApplyJob(string id, string expsal)
        {
            jpuser SessionUser = GetSessionUser();

            List <jpopening>            lstopening = jpopeningManager.Getjpopening("OPENINGID = '" + id + "'");
            List <jpopeningapplication> lst        = jpopeningapplicationManager.Getjpopeningapplication("OPENINGID = '" + id + "' and PROFILEID = '" + SessionUser.objjpprofile.PROFILEID + "'");

            jpopeningapplication obj = new jpopeningapplication();

            obj.OPENINGID      = int.Parse(id);
            obj.PROFILEID      = SessionUser.objjpprofile.PROFILEID;
            obj.EXPECTEDSALARY = expsal;
            obj.APPLIEDDATE    = DateTime.Now;

            string ret = jpopeningapplicationManager.Savejpopeningapplication(obj);

            if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
            {
                return(Shared.Constants.MSG_SUCCESS.Text);
            }

            return(Shared.Constants.MSG_ERROR.Text);
        }
        public string validateApplyJob(string id)
        {
            if (GetSessionUser() == null)
            {
                return(Shared.Constants.MSG_SESSION_USER_EMPTY.Text);
            }
            else
            {
                jpuser SessionUser = GetSessionUser();
                if (SessionUser.ACTIVE.Equals(Shared.Constants.STR_NO))
                {
                    return(Shared.Constants.MSG_SESSION_USER_UNV.Text);
                }

                List <jpopening> lstopening = jpopeningManager.Getjpopening("OPENINGID = '" + id + "'");
                if (lstopening.Count > 0)
                {
                    if (lstopening[Shared.Constants.ZERO].JOBSTATUS.Equals("C"))
                    {
                        return(Shared.Constants.MSG_POS_CLOSED.Text);
                    }
                }
                List <jpopeningapplication> lst = jpopeningapplicationManager.Getjpopeningapplication("OPENINGID = '" + id + "' and PROFILEID = '" + SessionUser.objjpprofile.PROFILEID + "'");
                if (lst.Count > 0)
                {
                    return(Shared.Constants.MSG_ALREADY_APPLIED.Text);
                }
                else
                {
                    if (!SessionUser.isProfileComplete)
                    {
                        return(Shared.Constants.MSG_SESSION_USER_INC_PROFILE.Text);
                    }
                    return(Shared.Constants.MSG_SUCCESS.Text);
                }
            }
        }
        public string _EduRecRemove(string id)
        {
            jpuser SessionUser = GetSessionUser();

            if (!string.IsNullOrEmpty(id))
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpqualification != null)
                        {
                            jpqualification obj = SessionUser.objjpprofile.lstjpqualification.Find(q => q.QUALIFICATIONID == int.Parse(id) && q.PROFILEID.Equals(SessionUser.objjpprofile.PROFILEID));
                            if (obj != null)
                            {
                                if (int.Parse(id) > 0)
                                {
                                    var ret = jpqualificationManager.Deletejpqualification(obj.QUALIFICATIONID);
                                    if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                                    {
                                        SessionUser.objjpprofile.lstjpqualification.Remove(obj);
                                        return(Shared.Constants.MSG_SUCCESS.Text);
                                    }
                                }
                                else
                                {
                                    SessionUser.objjpprofile.lstjpqualification.Remove(obj);
                                    return(Shared.Constants.MSG_SUCCESS.Text);
                                }
                            }
                        }
                    }
                }
            }
            return(Shared.Constants.MSG_ERROR.Text);
        }
        public string _ExpRecRemove(string id)
        {
            jpuser SessionUser = GetSessionUser();

            if (!string.IsNullOrEmpty(id))
            {
                if (SessionUser != null)
                {
                    if (SessionUser.objjpprofile != null)
                    {
                        if (SessionUser.objjpprofile.lstjpexperience != null)
                        {
                            jpexperience obj = SessionUser.objjpprofile.lstjpexperience.Find(q => q.EXPID == int.Parse(id) && q.PROFILEID.Equals(SessionUser.objjpprofile.PROFILEID));
                            if (obj != null)
                            {
                                if (int.Parse(id) > 0)
                                {
                                    var ret = jpexperienceManager.Deletejpexperience(obj.EXPID);
                                    if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                                    {
                                        SessionUser.objjpprofile.lstjpexperience.Remove(obj);
                                        return(Shared.Constants.MSG_SUCCESS.Text);
                                    }
                                }
                                else
                                {
                                    SessionUser.objjpprofile.lstjpexperience.Remove(obj);
                                    return(Shared.Constants.MSG_SUCCESS.Text);
                                }
                            }
                        }
                    }
                }
            }
            return(Shared.Constants.MSG_ERROR.Text);
        }
        public string MyProfile(jpprofile model)
        {
            jpuser SessionUser = GetSessionUser();

            if (SessionUser != null)
            {
                if (SessionUser.objjpprofile != null)
                {
                    if (SessionUser.objjpprofile.lstjpqualification.Count > 0)
                    {
                        if (SessionUser.objjpprofile.lstjpexperience.Count > 0)
                        {
                            SessionUser.objjpprofile.CONTACT         = model.CONTACT;
                            SessionUser.objjpprofile.CURRENTSALARY   = model.CURRENTSALARY;
                            SessionUser.objjpprofile.NAME            = model.NAME;
                            SessionUser.objjpprofile.GENDER          = model.GENDER;
                            SessionUser.objjpprofile.CURRENTCURRENCY = model.CURRENTCURRENCY;
                            SessionUser.objjpprofile.NATIONALITY     = model.NATIONALITY;
                            SessionUser.objjpprofile.LANGUAGE        = model.LANGUAGE;

                            SessionUser.objjpprofile.lstjpqualification.FindAll(a => a.QUALIFICATIONID < 0).Select(c => { c.QUALIFICATIONID = 0; return(c); }).ToList();
                            SessionUser.objjpprofile.lstjpexperience.FindAll(a => a.EXPID < 0).Select(c => { c.EXPID = 0; return(c); }).ToList();

                            MySqlConnection conn = Shared.BaseManager.PrimaryConnection();
                            conn.Open();
                            var    transaction = conn.BeginTransaction();
                            string ret         = jpprofileManager.Savejpprofile(SessionUser.objjpprofile, conn, transaction);
                            if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                            {
                                bool EduContinue = true;
                                //ret = jpqualificationManager.Deletejpqualification()
                                foreach (var edu in SessionUser.objjpprofile.lstjpqualification)
                                {
                                    ret = jpqualificationManager.Savejpqualification(edu, conn, transaction);
                                    if (!ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                                    {
                                        EduContinue = false;
                                        break;
                                    }
                                }

                                if (EduContinue)
                                {
                                    bool ExpContinue = true;
                                    foreach (var exp in SessionUser.objjpprofile.lstjpexperience)
                                    {
                                        ret = jpexperienceManager.Savejpexperience(exp, conn, transaction);
                                        if (!ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                                        {
                                            ExpContinue = false;
                                            break;
                                        }
                                    }
                                    if (ExpContinue)
                                    {
                                        transaction.Commit();
                                        conn.Close();
                                        conn.Dispose();

                                        SessionUser.objjpprofile      = GetCompleteUserProfile(SessionUser.USERID);
                                        SessionUser.isProfileComplete = isProfileComplete(SessionUser.objjpprofile);
                                        SetSessionUser(SessionUser);

                                        return(Shared.Constants.MSG_SUCCESS.Text);
                                    }
                                }
                            }

                            transaction.Rollback();
                            conn.Close();
                            conn.Dispose();
                            return(Shared.Constants.MSG_ERR_SERVER.Text);
                        }
                    }
                }
            }

            return(Shared.Constants.MSG_ERROR.Text);
        }
 public void SetSessionUser(jpuser obj)
 {
     Session[Shared.Constants.SESSION_USER] = obj;
 }
        private object getVerificationURL(jpuser obj)
        {
            var payload = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).ToDictionary(prop => prop.Name, prop => prop.GetValue(obj, null));

            return(Shared.Utility.encodeJWT(payload));
        }