Exemple #1
0
        public string Log(string username, string pass)
        {
            //from android comes like this - ?-360
            CallContext resultContext = new UserBL().Login(username, pass, null);
            UserProps userProps = new UserProps();

            if (resultContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {

                User currentUser = new UserBL().GetUserByUserID(resultContext.EntityID);

                if (currentUser != null)
                {

                    Person person = new PersonBL().GetPersonByPersonID(currentUser.idPerson.ToString());
                    userProps.PersonNamePlusTitle = person.FullNamePlusTitle;
                    userProps.PersonNameNoTitle = person.FullName;
                    userProps.PersonTwoNamePlusTitle = person.TwoNamesPlusTitle;
                    userProps.PersonID = person.idPerson.ToString();

                    userProps.LoginDateTime = DateTime.Now;
                    
                    
                    
                    userProps.idStudent = Constants.INVALID_ID;

                }

            }

            var jsonSerialiser = new JavaScriptSerializer();
            var json = jsonSerialiser.Serialize(userProps);

            return json;
        }
        public void AuthUser(string username, string password)
        {
            User userToAuth = new User();

            userToAuth.UserName = username.ToLower();
            userToAuth.Password = password;

            var result = new UserBL().AutenticateLogin(userToAuth);

            if (result != null)
            {
                var session = new SLIIT.ITP.SLLITPage();

                session.CurrentUserID = result.RnUserID;

            }
            else
            {
                throw new Exception(SLIITCommonResource.ERROR_Incorrect_Credentials.ToString());
            }
        }
        public bool ValidateEmail(string email, int id = -1)
        {
            int emailCount = 0;

            if (id != -1)
            {
                emailCount = new UserBL().GetActiveUserList(de).Where(x => x.Email.ToLower() == email.ToLower() && x.Id != id && x.IsActive != 0).Count();
            }
            else
            {
                emailCount = new UserBL().GetActiveUserList(de).Where(x => x.Email.ToLower() == email.ToLower() && x.IsActive != 0).Count();
            }

            if (emailCount > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemple #4
0
        private void OkBtn_Click(object sender, RoutedEventArgs e)
        {
            UserBL user       = new UserBL();
            var    mainWindow = this.Owner as MainWindow;

            if (mainWindow != null)
            {
                user = mainWindow.user;
            }
            if (user.CheckPassword(password.Password))
            {
                MessageBox.Show("Passwords match");
            }
            else
            {
                MessageBox.Show("Password does not match, please try again");
            }
            password.ClearEdit();
            PasswordTxtbx.TextChanged -= PasswordTxtbx_TextChanged;
            PasswordTxtbx.Clear();
            PasswordTxtbx.TextChanged += PasswordTxtbx_TextChanged;
        }
Exemple #5
0
        /// <summary>
        /// Starts registration process
        /// </summary>
        /// <param name="fEmail"></param>
        protected void Initiate(string fEmail)
        {
            if (Page.IsValid)
            {
                UserModel newUser = new UserModel();

                //Stores details as supplied by user
                newUser.Email           = fEmail.ToLower();
                newUser.Password        = inPassword.Value;
                newUser.FirstName       = inFirstName.Value;
                newUser.LastName        = inLastName.Value;
                newUser.AdminPermission = 0;
                newUser.phoneNum        = inPhone.Value;

                //Adds new user to database
                UserBL.ProcessAddNewUser(newUser);

                NotifyBL.startAccountNotification(fEmail, inPhone.Value, inFirstName.Value, inLastName.Value);

                Response.Redirect("Home.aspx");
            }
        }
        public ActionResult Register(FormCollection collection)
        {
            UserBL user = new UserBL
            {
                Email          = collection["registerUserEmail"],
                PasswordHashed = collection["registerUserPassword"],
                FirstName      = collection["registerUserName"],
                LastName       = "Guest",
                Flags          = UserFlagsBL.Default,
                JoinDate       = DateTime.Now,
                UserType       = UserTypeBL.Member
            };

            var userId = KitBL.Instance.Users.Insert(user);

            var success       = AsyncUserLogin(user.Email, user.PasswordHashed);
            var emailTemplate = KitBL.Instance.EmailTemplate.GetByName("GeneralRegister");

            SMTP.sendEmail("*****@*****.**", user.Email, emailTemplate.Subject, emailTemplate.Structure);

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Details(int id)
        {
            TodoItemBL todoItemBL = new TodoItemBL();
            TodoItem   todoItem   = todoItemBL.GetItemByID(id);

            if (todoItem == null)
            {
                return(RedirectToAction("Forbidden"));
            }
            string loggedUser = (string)Session["LoggedUser"];
            UserBL userBL     = new UserBL();
            int    userID     = userBL.GetLoggedUserID(loggedUser);

            if (todoItem.UserID != userID)
            {
                return(RedirectToAction("Forbidden"));
            }

            DetailsVM vm = new DetailsVM(todoItem);

            return(View(vm));
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["email"] != null)
                {
                    DataSet dt           = new DataSet();
                    string  teacherEmail = Session["email"].ToString();
                    dt              = UserBL.FetchTeacherFullProfileUsingEmail(teacherEmail);
                    txtname.Text    = dt.Tables[0].Rows[0].ItemArray[1].ToString();
                    txtsubject.Text = dt.Tables[0].Rows[0].ItemArray[4].ToString();
                    ContactNo.Text  = dt.Tables[0].Rows[0].ItemArray[3].ToString();
                    txtaddress.Text = dt.Tables[0].Rows[0].ItemArray[9].ToString();
                    string path = dt.Tables[0].Rows[0].ItemArray[5].ToString();
                    txtqualification.Text = dt.Tables[0].Rows[0].ItemArray[6].ToString();
                    // Session["RemvPicStatus"] = null;
                    Session["chpicstatus"] = null;
                    Session["UpPicStatus"] = null;
                    lnkChangePic.Visible   = false;
                    lnkRemovePic.Visible   = false;
                    lnkUploadPic.Visible   = true;

                    if (path != "")
                    {
                        imgProfile.Src          = path;
                        Session["profileimage"] = dt.Tables[0].Rows[0].ItemArray[5].ToString();
                        lnkChangePic.Visible    = true;
                        lnkRemovePic.Visible    = true;
                        lnkUploadPic.Visible    = false;
                    }
                }
                else
                {
                    Response.Redirect("~/UI/LogRegister.aspx", false);
                }
                flechImage.Attributes["onchange"]  = "ChangeFile(this)";
                FleUplImage.Attributes["onchange"] = "UploadFile(this)";
            }
        }
Exemple #9
0
        public ActionResult Register(RegisterVM vm)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("CredentialError", errorMessage: "Wrong username or password");
                return(View(vm));
            }

            UserBL userBL = new UserBL();

            if (userBL.isUniqueName(vm.UserName))
            {
                userBL.AddUser(vm);
            }
            else
            {
                ModelState.AddModelError("CredentialError", errorMessage: "Username is taken, choose another");
                return(View(vm));
            }

            return(RedirectToAction("Login"));
        }
    protected void BtnRegister_Click(object sender, EventArgs e)
    {
        int userid = 0;

        userbl = new UserBL();
        setdto();

        userid = userbl.RegisterUser(userdto);

        if (userid == -1)
        {
            divmessage.Style["display"] = "block";
        }
        else
        {
            HttpCookie cookie = new HttpCookie("QA");
            cookie.Values.Add("Uid", userid.ToString());
            cookie.Values.Add("UserName", TxtEmail.Text);
            Response.SetCookie(cookie);
            Response.Redirect("~/Home.aspx");
        }
    }
Exemple #11
0
        public ActionResult Login(User user, string ReturnUrl)
        {
            UserBL userBL = new UserBL();

            if (userBL.IsValidUser(user.Username, user.Password))
            {
                Session["User"] = new User {
                    Username = user.Username
                };
                FormsAuthentication.SetAuthCookie(user.Username, false);
                if (ReturnUrl == null)
                {
                    return(RedirectToAction("BeltList", "Home"));
                }
                return(Redirect(ReturnUrl));
            }
            else
            {
                ModelState.AddModelError("CredentialError", "Niepoprawne hasło lub nazwa uzytkownika");
                return(View("Login"));
            }
        }
Exemple #12
0
        private void loadUser(int userID)
        {
            User user = UserBL.GetUser(userID, string.Empty);

            txtFirstName.Text = user.FirstName;
            txtLastName.Text  = user.LastName;
            txtUsername.Text  = user.Username;
            //txtPassword.Text = user.Password;
            cmbUserType.SelectedValue = cmbUserType.Items.FindByValue(user.UserType.UserTypeID.ToString()).Value;
            txtEmail.Text             = user.Email;
            txtPhone.Text             = user.Phone;
            txtAddress.Text           = user.Address;
            txtZip.Text      = user.Zip;
            txtCity.Text     = user.City;
            txtDiscount.Text = user.Discount.ToString();
            cmbDiscountType.SelectedValue = user.DiscountTypeID.ToString();
            Page.Title = user.Username;
            ViewState.Add("pageTitle", user.Username);
            lblUserID.Value    = user.UserID.ToString();
            chkActive.Checked  = user.Active;
            chkBlocked.Checked = user.Blocked;
        }
Exemple #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Session timeout
            UserBL session = (UserBL)Session["user"];


            if (session == null)
            {
                Response.Redirect("SessionTimeout.aspx");
            }

            //Needed this in page load or the textbox IDs would not be saved on page load
            foreach (string textboxId in TextBoxIdCollection)
            {
                // Adding validators to every textbox created
                var textbox = new TextBox {
                    ID = textboxId
                };
                RequiredFieldValidator validator = new RequiredFieldValidator();
                validator.ControlToValidate = textbox.ID;
                validator.ErrorMessage      = "Textbox cannot be empty";
                validator.ForeColor         = System.Drawing.ColorTranslator.FromHtml("#ff0000");
                validator.Display           = ValidatorDisplay.Dynamic;
                validator.Font.Size         = new System.Web.UI.WebControls.FontUnit("14px");
                RegularExpressionValidator validtorReg = new RegularExpressionValidator();
                validtorReg.ControlToValidate    = textbox.ID;
                validtorReg.ErrorMessage         = "Incorrect Email";
                validtorReg.ForeColor            = System.Drawing.ColorTranslator.FromHtml("#ff0000");
                validtorReg.Display              = ValidatorDisplay.Dynamic;
                validtorReg.Font.Size            = new System.Web.UI.WebControls.FontUnit("14px");
                validtorReg.ValidationExpression = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
                textbox.Text      = "Email here";
                textbox.CssClass  = "input100";
                textbox.MaxLength = 30;
                PlaceHolder1.Controls.Add(validtorReg);
                PlaceHolder1.Controls.Add(validator);
                PlaceHolder1.Controls.Add(textbox);
            }
        }
Exemple #14
0
        protected void articlegrdvw_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row           = articlegrdvw.Rows[e.RowIndex];
            Label       id            = (Label)row.FindControl("lblquestionID");
            int         artid         = Int32.Parse(id.Text);
            FileUpload  materialquest = (FileUpload)row.FindControl("Upldmtrlquest");

            if (materialquest.HasFile)
            {
                Label   type     = (Label)row.FindControl("lblqtype");
                TextBox file     = (TextBox)row.FindControl("txtqfilename");
                string  filepath = file.Text.ToString();
                System.IO.File.Delete(Server.MapPath(filepath));
                string qry = string.Empty;

                if (type.Text.ToString() == "QUESTION PAPER")
                {
                    materialquest.SaveAs(Server.MapPath("/Upload/QuestionPapers/") + materialquest.FileName);
                    qry = "update tblquestionSyllabus set filename='/Upload/QuestionPapers/" + materialquest.FileName.Trim() + "' where id='" + artid + "'";
                }
                else if (type.Text.ToString() == "SYLLABUS")
                {
                    materialquest.SaveAs(Server.MapPath("/Upload/Syllabus/") + materialquest.FileName);
                    qry = "update tblquestionSyllabus set filename='/Upload/Syllabus/" + materialquest.FileName.Trim() + "' where id='" + artid + "'";
                }

                if (UserBL.UpdateDetails(qry))
                {
                    articlegrdvw.EditIndex = -1;
                    fillQgrid();
                    show = "Update";
                    Response.Redirect(Request.RawUrl);
                }
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                //string email = Session["email"].ToString();
                string email = Convert.ToString(Request.QueryString["mail"]);
                //   Response.Write(email);
                dt = UserBL.FetchDate(email);                                                // Fetch date and time of the link send to the user's email when he clicked forgot link.

                DateTime date1 = Convert.ToDateTime(dt.Rows[0][0]);                          // convert returned date and time(string) to datetime type.
                DateTime newDt = date1.AddMinutes(Convert.ToDouble(dt.Rows[0]["duration"])); //add minutes to the returned time.
                if (DateTime.Now > newDt)                                                    // checks visibility (date and time) upto which date or time the link remains visible in users email-id.
                {
                    lblmsg.Text = "Your link is expired";
                }
            }
            catch (Exception)
            {
                Response.Redirect("LogRegister.aspx");
            }
        }
        public ActionResult ToggleProduct(int Id)
        {
            if (sessiondto.getName() == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else if (sessiondto.getRole() != 3)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Product product = new UserBL().getProductById(Id);

                Product p = new Product()
                {
                    Id                = product.Id,
                    Name              = product.Name,
                    Category_Id       = product.Category_Id,
                    Minimum_Order     = product.Minimum_Order,
                    Delievery_Charges = product.Delievery_Charges,
                    Description       = product.Description,
                    User_Id           = product.User_Id
                };

                if (product.Is_Authorized == 0)
                {
                    p.Is_Authorized = 1;
                }
                else
                {
                    p.Is_Authorized = 0;
                }

                new UserBL().UpdateProduct(p);

                return(RedirectToAction("ListProducts", "Admin"));
            }
        }
        public static DriverDTO GetDriverDTO(Driver driver)
        {
            if (driver == null)
            {
                return(null);
            }
            User user = UserConverters.GetUser(UserBL.GetUser(driver.Identity));

            driver.User = user;
            DriverDTO driverDto = new DriverDTO()
            {
                Id             = driver.Id,
                Identity       = driver.Identity,
                Name           = driver.User.Name,
                Mail           = driver.User.Mail,
                Gender         = driver.User.Gender,
                NumberOfSeats  = driver.NumberOfSeats,
                CarDescription = driver.CarDescription
            };

            return(driverDto);
        }
        /// <summary>
        /// Searches the database for a user, searching by email
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void searchButton_Click(Object sender, EventArgs e)
        {
            UserModel record = new UserModel();

            //If no email is enetered, display an error on the user interface
            if (txbUsername.Value == null)
            {
                lblStatus.Text = "Please enter a valid Email";
            }
            else
            {
                //Search the database for a user with a matching email
                record = UserBL.passUserSearch(txbUsername.Value);

                //If no results are found, display an error on the user interface
                if (record == null)
                {
                    lblStatus.Text = "User not found, please try again";
                }
                else
                {
                    //Update display on user interface to reflect record with user values from the database
                    lblUserID.Text    = record.UserID.ToString();
                    Email.Value       = record.Email;
                    inPassword.Value  = record.Password;
                    inFirstName.Value = record.FirstName;
                    inLastName.Value  = record.LastName;

                    if (record.AdminPermission == 1)
                    {
                        chkAdmin.Checked = true;
                    }
                    else
                    {
                        chkAdmin.Checked = false;
                    }
                }
            }
        }
        public ActionResult EditProduct(int Id, string message = "")
        {
            if (sessiondto.getName() == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else if (sessiondto.getRole() == 0)
            {
                return(RedirectToAction("Index", "Account"));
            }
            else
            {
                List <Category> categories = new UserBL().getCategoryList();
                Product         p          = new UserBL().getProductById(Id);

                ViewBag.categories = categories;
                ViewBag.product    = p;
                ViewBag.message    = message;

                return(View());
            }
        }
Exemple #20
0
        public ActionResult DoEditCustomer(UserInfo userInfo, string GroupId)
        {
            var result = new ActionBusinessResult();

            try
            {
                var userBL = new UserBL();
                userInfo.ModifiedBy = SessionData.CurrentUser.Username;
                result = userBL.EditUser(userInfo, GroupId);

                if (SessionData.CurrentUser != null && result.IsActionSuccess == true && userInfo.Id == SessionData.CurrentUser.Id)
                {
                    SessionData.CurrentUser.loginfirst = 1;
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(Json(new { result = result.ToJson() }));
        }
Exemple #21
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");

            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure : false);

                if (result.Succeeded)
                {
                    _logger.LogInformation("Community_ASPNETUser logged in.");

                    var user = await _userManager.FindByEmailAsync(Input.Email);

                    var userId = user.Id;
                    UserBL.LogLogin(userId);
                    return(LocalRedirect(returnUrl));
                }
                if (result.RequiresTwoFactor)
                {
                    return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe }));
                }
                if (result.IsLockedOut)
                {
                    _logger.LogWarning("Community_ASPNETUser account locked out.");
                    return(RedirectToPage("./Lockout"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return(Page());
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Exemple #22
0
        public ActionResult Settings(string username, string password, string password2, string email, string email2)
        {
            string subdomain = UtilityHelper.GetSubdomain(HttpContext.Request.Headers["HOST"]);
            string username1 = HttpContext.User.Identity.Name;

            if (username.Equals(username1))
            {
                DataModel.User userObj = UserBL.GetUser(subdomain, username1);
                if (password.Equals(userObj.Password))
                {
                    //update without updating password
                    UserBL.UpdateUser(subdomain, username, email, true, null);
                }
                else
                {
                    //update user along with password
                    UserBL.UpdateUser(subdomain, username, password, email, true, null);
                }
                return(RedirectToAction("Index", "App"));
            }
            return(View());
        }
Exemple #23
0
        protected void ddllesson_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int lessonid = Convert.ToInt32(ddllesson.SelectedValue);
                Session["lessonid"] = lessonid;
                int classid, subjectid;
                classid   = Convert.ToInt32(Session["classid"]);
                subjectid = Convert.ToInt32(Session["subjectid"]);
                lessonid  = Convert.ToInt32(Session["lessonid"]);
                //  grddownloadmaterial.DataSource = UserBL.FetchVideomaterialdetails(classid, subjectid, lessonid, 1002);
                // grddownloadmaterial.DataBind();
                DataTable dsvid = UserBL.FetchVideomaterialdetails(classid, subjectid, lessonid, 2);
                Accordion1.DataSource = dsvid.DefaultView;
                Accordion1.DataBind();
                h3.Visible = true;
            }

            catch (Exception)
            {
            }
        }
Exemple #24
0
        protected void UserOnItemCommand(object sender, GridCommandEventArgs e)
        {
            string commandName = e.CommandName;

            if (e.CommandName == "EditUser")
            {
                string UserID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserID"].ToString();
                e.Item.Selected = true;

                foreach (Telerik.Web.UI.GridDataItem printerVal in userRd.SelectedItems)
                {
                    //Session["UserID"] = Convert.ToString(printerVal["UserID"].Text);
                    Session["Userid"]      = Convert.ToUInt32(UserID);
                    Session["UserName"]    = Convert.ToString(printerVal["UserName"].Text);
                    Session["LastName"]    = Convert.ToString(printerVal["LastName"].Text);
                    Session["FirstName"]   = Convert.ToString(printerVal["FirstName"].Text);
                    Session["Email"]       = Convert.ToString(printerVal["Email"].Text);
                    Session["Address"]     = Convert.ToString(printerVal["Address"].Text);
                    Session["DOB"]         = Convert.ToDateTime(printerVal["DOB"].Text);
                    Session["CreatedDate"] = Convert.ToDateTime(printerVal["CreatedDate"].Text);
                }
                string script = "function f(){Open('" + userupdatepopup.ClientID + "'); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            }
            else if (e.CommandName == "DeleteUser")
            {
                string Userid = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserID"].ToString();
            }
            else if (e.CommandName == "Profile")
            {
                string id     = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserID"].ToString();
                int    userid = Convert.ToInt32(id);

                UserBL userBL = new UserBL();
                Session["useridsession"] = userBL.getUsername(userid);

                Response.Redirect("NewReport.aspx");
            }
        }
Exemple #25
0
        protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                Guid   g = Guid.NewGuid();
                Random r = new Random();                     // Admin generates an random number
                int    i = r.Next();

                Label  lblemail = GridView3.Rows[e.RowIndex].FindControl("lblemail") as Label;     // Gives index of email field in the grid.
                string email    = lblemail.Text;                                                   // put data of that index in the variable.

                string id  = GridView3.DataKeys[e.RowIndex].Value.ToString();                      // Gives index of primary key (id) in the grid.
                int    ide = Convert.ToInt32(id);                                                  // converts id to int .

                TextBox tb  = GridView3.Rows[e.RowIndex].FindControl("txtlock") as TextBox;        // Gives index of lock field in the grid.
                string  tb1 = Convert.ToString(tb);
                int     tb2;

                int.TryParse(tb1, out tb2);                     // converts data of textbox limit to int
                UserBL.InsertRandomIntoPassWord(i, email, ide); // Function to put random number (i) in the password field of that particular user.
                if (UserBL.UpdateBlockedUsers(ide, tb2, email)) // Function to update the lock of particular user. Also update his limit field to zero .
                {
                    show = "Update";
                }

                StringBuilder sb = new StringBuilder();               // creates a string and sends it to blocked user along with the random number(i) as a password which he can use to login.
                //sb.Append("<img src='../img/logo.jpg' height='180' width='150' /><br>");
                sb.Append("Dear User! <br/>Kindly login with this new password : "******"<br/> After  login you must reset your password " + " <a href='http://www.sidza.com' target='_blank'>click here</a><br/>");
                sb.Append("Contact us for any queries or suggestions at <b>[email protected]</b><br/>.Best Regards<br/><a href='http://www.sidza.com'>SIDZA.COM</a><br/>");
                Email.SendEmail(email, "User Unblocked", sb.ToString());        // Function to send mail to the blocked user.

                //   GridView3.EditIndex = -1;
                showgrid();
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception)
            { }
        }
Exemple #26
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            if (actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Count > 0)
            {
                return;
            }
            ;

            if (actionContext.Request.Headers.Authorization == null)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
            else
            {
                string   token         = actionContext.Request.Headers.Authorization.Parameter;
                string   decodedString = CryptoHelper.Decrypt(token, Constants.ENCRYPTION_KEY);
                string[] tokensValues  = decodedString.Split(Constants.TOKEN_SEPARATOR);

                var roleName = new UserBL().GetUserRoles(tokensValues[0], tokensValues[1]);

                if (roleName != null)
                {
                    IPrincipal principal = new GenericPrincipal(new GenericIdentity(tokensValues[0]), new string[] { roleName });
                    Thread.CurrentPrincipal  = principal;
                    HttpContext.Current.User = principal;
                }
                else
                {
                    //The user is unauthorize and return 401 status
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.InternalServerError);
            //}
        }
        public ActionResult DetailsPost(UserDetailsVM objDetailsVM, string Submit, HttpPostedFileBase file)
        {
            CommonBL objCommonBL = null;

            try
            {
                if (Submit == "Save")
                {
                    objUserBL   = new UserBL();
                    objCommonBL = new CommonBL();

                    objDetailsVM.User.Status = 1;
                    if (file != null)
                    {
                        string path = "~/Content/profileimages/" + Guid.NewGuid() + file.FileName;
                        file.SaveAs(Server.MapPath(path));
                        objDetailsVM.User.ImageUrl = path;//.Substring(2, path.Length - 2);
                    }
                    objResponse = objUserBL.SaveUser(objDetailsVM.User, objDetailsVM.User.UserId > 0 ? "U" : "C");
                    objDetailsVM.lstUserTypes = objCommonBL.GetCodeDetail(new CodeDetailFilter()
                    {
                        CodeTypeId = 1
                    });
                    objDetailsVM.Toast = WebCommon.SetToast(objResponse, "User", "Index");
                }
                return(View(objDetailsVM));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objUserBL    = null;
                objDetailsVM = null;
                objCommonBL  = null;
            }
        }
        public ActionResult InternationalCategoryProducts(int Id)
        {
            Category       category         = new UserBL().getCategoryById(Id);
            List <Product> categoryproducts = new List <Product>();

            //Father Category
            if (category.Category_Id == null)
            {
                List <Category> subcategories = new UserBL().getCategoryList().Where(x => x.Category_Id == Id).ToList();
                foreach (Category c in subcategories)
                {
                    Product p = new UserBL().getProductList().Where(x => x.Category_Id == c.Id).FirstOrDefault();

                    if (p != null && p.User.Role == 2)
                    {
                        categoryproducts.Add(p);
                    }
                }
                ViewBag.categoryproducts = categoryproducts.OrderByDescending(x => x.Id);
                ViewBag.subcategories    = subcategories;
            }
            //Son Category
            else
            {
                categoryproducts = new UserBL().getProductList().Where(x => x.Category_Id == Id && x.User.Role == 2).OrderByDescending(x => x.Id).ToList();
                Category parentcategory = new UserBL().getCategoryById(Convert.ToInt32(category.Category_Id));

                if (categoryproducts != null)
                {
                    ViewBag.categoryproducts = categoryproducts;
                    ViewBag.parentcategory   = parentcategory;
                }
            }


            ViewBag.category = category;
            return(View("CategoryProducts"));
        }
Exemple #29
0
        public ActionResult PostAdminEditUser(User _user)
        {
            try
            {
                if (ValidateLogin() == false)
                {
                    return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from ADMIN DashBoard, plz login again", color = "Red" }));
                }

                bool chkEmail = gp.ValidateEmail(_user.Email, _user.Id);
                if (chkEmail == false)
                {
                    return(RedirectToAction("AdminEditUser", "Admin", new { msg = "Emaial exists", color = "Red" }));
                }

                User updateAdmin = new UserBL().GetUserById(_user.Id, db);
                updateAdmin.FirstName = _user.FirstName.Trim();
                updateAdmin.LastName  = _user.LastName.Trim();
                updateAdmin.Contact   = _user.Contact.Trim();
                updateAdmin.Password  = _user.Password.Trim();
                updateAdmin.Email     = _user.Email.Trim();

                bool checkUser = new UserBL().UpdateUser(updateAdmin, db);

                if (checkUser == true)
                {
                    return(RedirectToAction("AdminViewUser", new { msg = "User has been Edited", color = "green" }));
                }
                else
                {
                    return(RedirectToAction("AdminEditUser", new { msg = "User has not been Edited cuz either you enter any empty/Null Value or Email you enter exist in DB", color = "Red" }));
                }
            }
            catch
            {
                return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found ", color = "Red" }));
            }
        }
Exemple #30
0
        private void kryBtnSel_Click(object sender, EventArgs e)
        {
            int selIndex = this.kryCbxSel.SelectedIndex;

            switch (selIndex)
            {
            case 0:
            {
                UserBL      bl    = new UserBL();
                List <User> users = bl.GetUsers();
                this.bindSrcUsers.DataSource = users;
                kryDgvMng.DataSource         = this.bindSrcUsers;
                break;
            }

            case 1:
            {
                DbConnBL      bl    = new DbConnBL();
                List <DbConn> conns = bl.GetDbConns();
                this.bindSrcDbConns.DataSource = conns;
                kryDgvMng.DataSource           = this.bindSrcDbConns;
                break;
            }

            case 2:
            {
                SqlSentenceBL      bl   = new SqlSentenceBL();
                List <SqlSentence> sqls = bl.GetSqls();
                this.bindSrcSqls.DataSource = sqls;
                kryDgvMng.DataSource        = this.bindSrcSqls;
                break;
            }

            default:
                KryptonMessageBox.Show("请选择配置表!");
                break;
            }
        }
Exemple #31
0
        public ActionResult AdminViewUser(string msg = "", string color = "black", string Name = "", string Email = "", string Contact = "")
        {
            try
            {
                if (ValidateLogin() == false)
                {
                    return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from ADMIN DashBoard, plz login again", color = "Red" }));
                }

                List <User> userslist = new UserBL().GetActiveUserList(db).Where(x => x.Role != 1).ToList();
                int         bookCount = new BookBL().GetActiveBookList(db).Count();
                if (Name != "")
                {
                    userslist = userslist.Where(x => x.FirstName.ToLower().Contains(Name.ToLower()) || x.LastName.ToLower().Contains(Name.ToLower())).ToList();
                }
                if (Email != "")
                {
                    userslist = userslist.Where(x => x.Email.ToLower().Contains(Email.ToLower())).ToList();
                }
                if (Contact != "")
                {
                    userslist = userslist.Where(x => x.Contact.ToLower().Contains(Contact.ToLower())).ToList();
                }

                ViewBag.msg      = msg;
                ViewBag.color    = color;
                ViewBag.userlist = userslist;
                ViewBag.Name     = Name;
                ViewBag.Email    = Email;
                ViewBag.Contact  = Contact;

                return(View());
            }
            catch
            {
                return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found", color = "Red" }));
            }
        }
Exemple #32
0
        public ActionResult SearchCustomerRegis(string pKeySearch, int pNumPage)
        {
            var lstUsers = new List <RegisterInfo>();

            try
            {
                decimal totalRecord = 0;
                var     userBL      = new UserBL();
                int     p_to        = 0;
                int     p_from      = CommonFuc.GetFromToPage(pNumPage, ref p_to);
                lstUsers         = userBL.RegisterGetAll(pKeySearch, p_from, p_to, ref totalRecord);
                ViewBag.lstUsers = lstUsers;
                string htmlPaging = WebApps.CommonFunction.AppsCommon.Get_HtmlPaging <RegisterInfo>((int)totalRecord, 1, "bản ghi", 10, "jsPageKH");
                ViewBag.Paging = htmlPaging;
                return(PartialView("~/Areas/ModuleUsersAndRoles/Views/User/_PartialTableListRegistor.cshtml"));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(PartialView("~/Areas/ModuleUsersAndRoles/Views/User/_PartialTableListRegistor.cshtml"));
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            //			Profile.EnableUpdatesOnAccessTokenChange (true);
            //			Settings.AppID = appId;
            //			Settings.DisplayName = appName;
            UserDetails = new UserDetails();
            UserProfile = new Profile ();
            leadsBL = new LeadsBL ();
            eventStore = new EKEventStore ( );
            CalendarList = new List<CalenderEvent> ();
            customerBL = new CustomerBL ();
            IsUpdateLeadDone = false;
            referralRequestBL = new ReferralRequestBL ();
            CurrentRRList = new List<ReferralRequest> ();
            userBL = new UserBL ();
            brokerBL = new BrokerBL ();
            industryBL = new IndustryBL ();

            //			UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false);

            // Code to start the Xamarin Test Cloud Agent
            #if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
            #endif

            //return ApplicationDelegate.SharedInstance.FinishedLaunching (application, launchOptions);
            return true;
        }
Exemple #34
0
        private void setUserDetails()
        {
            var session = new SLLITPage();

            var user = new UserBL().GetUserByID(session.CurrentUserID);

            lblUserName.Text = user.DisplayName;
        }
 public UserController()
 {
     this.user_bl = new UserBL();
 }