Пример #1
0
        public static bool PostJob(JobDetailsModel model)
        {
            var post = JobsContext.PostJob(new JobDetail()
            {
                job_details_id   = model.Job_details_id,
                job_organization = model.Job_organization,
                job_img          = "",
                employee_id      = RegistrationProvider.GetUseridfromUsername(model.username),
                job_date         = model.Job_date,
                job_applied_date = DateTime.Now,
                job_description  = model.Job_description,
                job_title        = model.Job_title,
                jo_date_modified = DateTime.Now,
                job_city         = model.Job_city,
                job_type         = model.Job_type
            });

            if (post > 0)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public static Response LoginFunc(LoginModel model)
        {
            // long id = 0;
            Response res     = new Response();
            bool     isFirst = false;

            try
            {
                if (model != null)
                {
                    if (RegistrationProvider.CheckUser(model.Username))
                    {
                        var membershipProvider1 = Membership.Providers["WebMembershipProvider"];
                        //var membershipProvider2 = Membership.Providers["WebMembershipProvider1"];
                        res.IsValid = membershipProvider1.ValidateUser(model.Username, model.Password);
                        //res.IsValid = Membership.ValidateUser(model.Username, model.Password);

                        if (res.IsValid)
                        {
                            isFirst = RegistrationProvider.IsFirstLogin(model.Username);

                            var      LogInCheckPoint = RegistrationProvider.LoginCheckPoint(model.Username, model.IpAddress, isFirst, model.Type);
                            string   MsgResponse     = LogInCheckPoint.ErrorMessage;
                            string   DateUTC         = Convert.ToString(DateTime.Now);
                            string[] strArr          = null;
                            char[]   splitchar       = { '|' };
                            strArr = MsgResponse.Split(splitchar);
                            string MessageNo   = strArr[0];
                            string MessageText = strArr[1];
                            if (MessageNo == "S")
                            {
                                if (isFirst)
                                {
                                    res.IsValid      = true;
                                    res.ErrorCode    = ((int)ErrorProvider.ErrorCode.FirstLogin).ToString();
                                    res.ErrorMessage = "Logged In Successfully.";
                                    return(res);
                                }
                                else
                                {
                                    res.IsValid      = true;
                                    res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginSuccess).ToString();
                                    res.ErrorMessage = "Logged In Successfully.";
                                    return(res);
                                }
                            }

                            else
                            {
                                res.IsValid      = false;
                                res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginFailure).ToString();
                                res.ErrorMessage = "LogIn Failed";
                                return(res);
                            }
                        }
                    }
                    else
                    {
                        res.IsValid      = false;
                        res.ErrorCode    = ((int)ErrorProvider.ErrorCode.UserNotExist).ToString();
                        res.ErrorMessage = "User Does not Exist";
                        return(res);
                    }
                }
                else
                {
                    res.IsValid      = false;
                    res.ErrorCode    = ((int)ErrorProvider.ErrorCode.Failure).ToString();
                    res.ErrorMessage = "SignIn Failed";
                    return(res);
                }
                return(res);
            }
            catch (Exception ex)
            {
                string[] strResponse = null;
                char[]   splitmsg    = { '|' };
                strResponse = ex.ToString().Split(splitmsg);
                string error_message = strResponse[2];

                if (strResponse[1] == "R")
                {
                    var    LoginFailed = RegistrationProvider.LoginFailedCheck(model.Username, model.IpAddress);
                    string MsgResponse = LoginFailed.ErrorMessage;

                    string[] strArr    = null;
                    char[]   splitchar = { '|' };

                    strArr = MsgResponse.Split(splitchar);
                    if (strArr.Count() == 2)
                    {
                        string MessageNo   = strArr[0];
                        string MessageText = strArr[1];


                        if (MessageNo == "OB")
                        {
                            res.IsValid      = false;
                            res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginFailure).ToString();
                            res.ErrorMessage = MessageText;
                            //res.FailedCount = context.Session["LoginAttempts"].ToString();
                            return(res);
                            //send mail
                        }
                        else if (MessageNo == "B")
                        {
                            res.IsValid      = false;
                            res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginFailure).ToString();
                            res.ErrorMessage = MessageText;
                            //res.FailedCount = context.Session["LoginAttempts"].ToString();
                            return(res);
                            //send mail
                        }
                        else
                        {
                            res.IsValid      = false;
                            res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginFailure).ToString();
                            res.ErrorMessage = MessageText;
                            //res.FailedCount = context.Session["LoginAttempts"].ToString();
                            return(res);
                        }
                    }
                    else
                    {
                        res.IsValid      = false;
                        res.ErrorCode    = ((int)ErrorProvider.ErrorCode.InvalidUserNamePass).ToString();
                        res.ErrorMessage = "Invalid Username or Password";
                        //res.FailedCount = context.Session["LoginAttempts"].ToString();
                    }
                }
                else
                {
                    res.IsValid      = false;
                    res.ErrorCode    = ((int)ErrorProvider.ErrorCode.LoginFailure).ToString();
                    res.ErrorMessage = error_message;
                    //res.FailedCount = loginitem.ToString();
                    return(res);
                }

                return(res);
            }
        }