Esempio n. 1
0
        public async Task <IActionResult> Create(UserAddInfo user)
        {
            try
            {
                UserCreateCommand userCreate = new UserCreateCommand()
                {
                    Email         = user.Email,
                    FirstName     = user.FirstName,
                    LastName      = user.LastName,
                    Password      = user.Password,
                    Phone         = user.Phone,
                    UserName      = user.UserName,
                    SocialAddress = new Domain.SocialMedia(instageram: user.Instageram, telegramCanal: user.TelegramCanal, telegramGroup: user.TelegramGroup),
                    Address       = new Domain.Address(street: user.Street, city: user.City, state: user.State, country: user.Country, zipcode: user.ZipCode)
                };

                var result = await _mediator.Send(userCreate);

                return(Ok(result));
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public override IUserAddInfo CreateUserAddInfo(IUser user)
        {
            UserAddInfo result = new UserAddInfo();

            result.UserId = user.UserId;

            return(result);
        }
Esempio n. 3
0
        //This method is used 2 times once in Login.cs and the other in User_add.cs
        //To retrieve User Data based on the UserID input in Login.aspx
        //To retrieve selected User data based on the selected row in User_Management.aspx
        //The parameter used to identify the selected row is the UserID
        public UserAddInfo GetData(string UserID)
        {
            UserAddInfo user = new UserAddInfo();
            DataTable   dt;
            string      commandtext = "SELECT Full_Name, Email_Addr, Role_Type FROM admin.TBL_USERS WHERE User_Name = @user_name";

            dt         = dbhelp.ExecDataReader(commandtext, "@user_name", UserID);
            user.Name  = dt.Rows[0]["Full_Name"].ToString();
            user.Email = dt.Rows[0]["Email_Addr"].ToString();
            user.Role  = dt.Rows[0]["Role_Type"].ToString();
            return(user);
        }
Esempio n. 4
0
        protected void Login_Click(object sender, EventArgs e)
        {
            try
            {
                DatabaseDAO userObj = new DatabaseDAO();
                UserAddInfo user    = new UserAddInfo();


                // Get user Roles, Name and Email to store in session of MasterPage and
                user = userObj.GetData(User_Login.Value);
                string role = user.Role;

                string Name  = user.Name;
                string Email = user.Email;
                if (role != null || Name != null || Email != null)
                {
                    // If User information correct, let user login
                    if (role.Length > 1)
                    {
                        //Store role in session
                        Session.Add("role", role);
                        Session.Add("name", Name);
                        Session.Add("email", Email);

                        // After user successfully login
                        // Rirect to index2.aspx
                        Session["check"] = "";
                        Response.Redirect("User_Management.aspx");
                    }
                    else
                    {
                        // If User Information Wrong, display error message
                        Login_Alert.Attributes.CssStyle.Add("display", "block");
                    }
                }
                else
                {
                    // If system error, display error message through alert box
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('There seems to be a problem with the system! Contact the local Administrator');", true);
                }
            }
            catch (Exception ex)
            {
                //Catch all errors and write to ErrorLog.txt
                ErrorLog.WriteErrorLog(ex.ToString());
            }
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string UserID = (string)(Session["UserID"]);
                if (UserID == null)
                {
                    //If session "UserID" is equals null, means edit button event was triggered from User_Management.aspx table

                    title.InnerText = "User Management > Create User";
                    UserRegisterHeader.InnerText  = "Create Account Details";
                    User_Input_Name.Value         = "";
                    User_Input_Email.Value        = "";
                    Select_Permission_Level.Value = "";
                    User_Input_Username.Value     = "";
                }
                else
                {
                    DatabaseDAO dao  = new DatabaseDAO();
                    UserAddInfo user = new UserAddInfo();

                    //Get User data from GetData Method in DatabaseDAO
                    user = dao.GetData(UserID);
                    if (user.Name != null)
                    {
                        //If retrieved data "user.Name" is not equals null, means edit button event was triggered from User_Management.aspx table
                        //Change alert message text to updated


                        //Change title of page to Edit User
                        title.InnerText = "User Management > Edit User";
                        UserRegisterHeader.InnerText = "Update Account Details";

                        //Sets the textbox values to the values retrieved from GetData Method in DatabaseDAO
                        User_Input_Username.Value     = UserID;
                        User_Input_Email.Value        = user.Email;
                        Select_Permission_Level.Value = user.Role;
                        User_Input_Name.Value         = user.Name;
                    }
                    else
                    {
                        //If error, display failure message
                        ScriptManager.RegisterStartupScript(Page, GetType(), "AlertFailureDisplay", "displayFailure();", true);
                    }
                }
            }
        }
Esempio n. 6
0
        public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFileBase imageFile)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };

                var additionalInfo = new UserAddInfo
                {
                    Id        = user.Id,
                    FirstName = model.FirstName,
                    LastName  = model.LastName
                };

                additionalInfo.Image = ImageHelper.SaveImage(Server, imageFile);

                user.UserAddInfo = additionalInfo;

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    UserManager.AddToRole(user.Id, "User");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }