コード例 #1
0
        public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            base.OnAuthorization(actionContext);
            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
            else
            {
                string   encodedString = actionContext.Request.Headers.Authorization.Parameter;
                string   decodedString = Encoding.UTF8.GetString(Convert.FromBase64String(encodedString));
                string[] arr           = decodedString.Split(new char[] { ':' });
                string   username      = arr[0];
                string   password      = arr[1];

                LORepository urepo = new LORepository();

                if (username == urepo.Get(username).LOfficer_name&& password == urepo.Get(username).LOfficer_Password)
                {
                    Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(username), null);
                }
                else
                {
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                }
            }
        }
コード例 #2
0
        public ActionResult ConfirmChangePassword(string oldpass, string Pass, string cpass)
        {
            LORepository    orepo = new LORepository();
            LoginRepository lrepo = new LoginRepository();

            LoanOfficer of = orepo.Get(Convert.ToInt32(Session["Id"]));

            Logininfo log = lrepo.Get(Session["Name"].ToString());

            if (Session["Password"].ToString() == oldpass)
            {
                if (Pass != cpass)
                {
                    ViewData["Message"] = "Password Didn't match";
                }
                else
                {
                    of.LOfficer_Password = Pass;
                    log.Login_Password   = Pass;

                    orepo.Update(of);
                    lrepo.Update(log);

                    ViewData["Message"] = "Password Updated Successfully";
                    Session["Officer"]  = of;
                    Session["Password"] = Pass;
                }
            }
            else
            {
                ViewData["Message"] = "Wrong Password";
            }

            return(View("Empty"));
        }
コード例 #3
0
        public ActionResult ConfirmLoanOfficer_Salary(int LOfficer_Id)
        {
            LORepository brepo = new LORepository();
            LoanOfficer  br    = brepo.Get(LOfficer_Id);
            DateTime     d     = DateTime.Now;

            if (d >= Convert.ToDateTime(br.LOfficer_LastPaymentDate).AddDays(30))
            {
                br.LOfficer_LastPaymentDate = d.ToString();
                br.LOfficer_TotalPayment   += br.LOfficer_Salary;
                br.LOfficer_Balance        += br.LOfficer_Salary;

                brepo.Update(br);
                ViewData["Message"] = "Salary Payment Successfull";
            }
            else
            {
                ViewData["Message"] = "To Early to Pay Salary";
            }

            return(View("Empty"));
        }