Example #1
0
 //Save button click that makes the updates
 private void button1_Click_1(object sender, EventArgs e)
 {
     if (datachange == true)
     {
         NormalUser nu = (NormalUser)x;
         Profile    up = nu.GetProfile();
         up.UpdateUserName(Id, usernamTextBox.Text);
         if (usernameExist.Visible == true)
         {
             usernameExist.Visible = false;
         }
         up.UpdateAddress(Id, adressTextBox.Text);
         up.UpdateEmail(Id, emailTextBox.Text);
         if (emailExist.Visible == true)
         {
             emailExist.Visible = false;
         }
         up.UpdateFirstName(Id, onomaTextBox.Text);
         up.UpdateLastName(Id, lastnameTextBox.Text);
         MessageBox.Show("Οι αλλαγές πραγματοποιήθηκαν.");
         string pass = nu.GetPass();
         InstanceOfUser.LogOut();
         InstanceOfUser.CreateCustomerUser(usrname, pass);
     }
     else
     {
         MessageBox.Show("Δεν έγινε κάποια αλλαγή για να αλλάξουν τα δεδομένα");
     }
 }
Example #2
0
        private Player CreatePlayerFromReader(OracleDataReader reader, List <Region> regions)
        {
            NormalUser u            = CreateNormalUserFromReader(reader, regions);
            string     summonerName = Convert.ToString(reader["summonerName"]);

            return(new Player(u.LoginName, u.Password, u.Email, u.Region, u.DateOfBirth, u.NewsLetter, summonerName));
        }
        public HttpResponseMessage Signup(NormalUser normalUser)
        {
            UnitOfWork myUnitOfWork = new UnitOfWork(new VoucherWorldContext());

            var emails =
                myUnitOfWork.Repository <User>()
                .Query()
                .Select(u => u.Email)
                .ToList();

            var usernames =
                myUnitOfWork.Repository <User>()
                .Query()
                .Select(u => u.UserName)
                .ToList();

            if (emails.Contains(normalUser.Email) || usernames.Contains(normalUser.UserName))
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, "UserName or Email already exists"));
            }

            normalUser.ObjectState = ObjectState.Added;

            myUnitOfWork.Repository <NormalUser>().InsertGraph(normalUser);

            myUnitOfWork.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, normalUser));
        }
        public async Task <ActionResult> Register(NormalUser user)
        {
            if (ModelState.IsValid)
            {
                normuser.UserName     = user.UserName;
                normuser.Email        = user.Email;
                normuser.UserPassword = user.UserPassword;
                CreateUsers users = new CreateUsers();
                users.UserName = normuser.UserName;
                users.Email    = normuser.Email;
                var resulter = await usmanager.CreateAsync(users, normuser.UserPassword);

                if (resulter.Succeeded)
                {
                    return(RedirectToAction("SignIn", "Account"));
                }
                else
                {
                    foreach (var item in resulter.Errors)
                    {
                        ModelState.AddModelError("", item.Description);
                    }
                }
            }
            return(View((NormalUser)normuser));
        }
Example #5
0
        public BookingStep2(int id, string date, string pay_type, int normal, int reduced)
        {
            InitializeComponent();
            //pairno titlo tou event
            Event ev = new Event(id);

            //pairno ta tickets
            enventDataSetTableAdapters.ticketsTableAdapter tick = new enventDataSetTableAdapters.ticketsTableAdapter();
            float normal_ticket_price  = (float)tick.GetNormalPriceEventId(id);
            float reduced_ticket_price = (float)tick.GetReducedPriceEventId(id);


            User x = InstanceOfUser.GetUser();

            Debug.WriteLine(x);
            if (x is Project_4.App_Code.NormalUser)
            {
                NormalUser nr = (NormalUser)x;
                name_label.Text = nr.GetProfile().GetLastName() + " " + nr.GetProfile().GetFirstName();
            }

            PlayTitle_label.Text      = ev.GetTitle();
            date_label.Text           = date;
            normalTickets_Label.Text  = normal.ToString();
            reducedTickets_Label.Text = reduced.ToString();
            label5.Text += "(" + normal_ticket_price + "€) :";
            label7.Text += "(" + reduced_ticket_price + "€) :";

            float total_price = normal_ticket_price * normal + reduced_ticket_price * reduced;

            total_Price.Text = total_price.ToString();
        }
Example #6
0
        private Employee CreateEmployeeFromReader(OracleDataReader reader, List <Region> regions)
        {
            NormalUser u        = CreateNormalUserFromReader(reader, regions);
            string     address  = Convert.ToString(reader["address"]);
            string     areaCode = Convert.ToString(reader["areaCode"]);
            string     jobTitle = Convert.ToString(reader["jobTitle"]);
            decimal    wage     = Convert.ToDecimal(reader["wage"]);

            return(new Employee(u.LoginName, u.Password, u.Email, u.Region, u.DateOfBirth, u.NewsLetter, address, areaCode, jobTitle, wage));
        }
        private void button_reset_pass_Click(object sender, EventArgs e)
        {
            NormalUser  nu = (NormalUser)InstanceOfUser.GetUser();
            int         id = nu.GetUserID();
            UserProfile ru = (UserProfile)nu.GetProfile();

            ru.UpdatePassword(id, txtResetPass.Text);
            recoverMsg.ForeColor = Color.Green;
            recoverMsg.Text      = "Ο κωδικός άλλαξε επιτυχώς!";
        }
Example #8
0
 internal InvoiceModel GenerateInvoice(NormalUser user, List <CartModel> list)
 {
     return(new InvoiceModel
     {
         UserId = user.Id,
         UserName = user.FirstName + user.LastName,
         ContactNo = user.PhoneNumber,
         Adress = user.Adress,
         MedList = list
     });
 }
Example #9
0
        public static void ShowMediator()
        {
            var mediator    = new SimpleMediator();
            var normalUser  = new NormalUser(mediator);
            var premiumUser = new PremiumUser(mediator);

            mediator.AddUser(normalUser);
            mediator.AddUser(premiumUser);

            normalUser.ChangeSubscription();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Dimiourgia antikeimenou gia na pame to email se alli klasi
            theEmail = EmailForgot.Text;


            User x = InstanceOfUser.GetUser();

            if ((x is Visitor) && (emailExists()))
            {
                Visitor vis = (Visitor)x;
                enventDataSetTableAdapters.userTableAdapter env = new enventDataSetTableAdapters.userTableAdapter();

                string username = env.returnUsernamePassword(theEmail).ToList().ElementAt(0).username;
                string password = env.returnUsernamePassword(theEmail).ToList().ElementAt(0).password;

                NormalUser nu = (NormalUser)vis.LogInAsNormalUser(username, password);
            }



            if (emailExists())
            {
                //Dimiourgia Random Verification Code
                Random rand = new Random();
                randomCode = (rand.Next(999999)).ToString();

                //Apostoli Email
                MailMessage mm = new MailMessage("*****@*****.**", EmailForgot.Text.Trim());
                mm.Subject    = "Κωδικός Επαναφοράς";
                mm.Body       = string.Format("Ο κωδικός επαναφοράς είναι: " + randomCode);
                mm.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host      = "smtp.gmail.com";
                smtp.EnableSsl = true;
                NetworkCredential NetworkCred = new NetworkCredential();
                NetworkCred.UserName       = "******";
                NetworkCred.Password       = "******";
                smtp.UseDefaultCredentials = true;
                smtp.Credentials           = NetworkCred;
                smtp.Port = 587;
                smtp.Send(mm);
                labelSend.ForeColor = Color.Green;
                labelSend.Text      = "Ο κωδικός επαναφοράς εστάλη επιτυχώς!";
            }
            else
            {
                labelSend.ForeColor = Color.Red;
                labelSend.Text      = "Το e-mail δεν βρέθηκε";
            }
        }
Example #11
0
        private bool AddEntry(String userType, JObject userInformation)
        {
            Boolean save = false;

            if (userType.Equals(UserContract.TABLE_ADMIN) || userType.Equals(UserContract.TABLE_NORMAL_USER) || userType.Equals(UserContract.TABLE_STORE_OWNER))
            {
                using (var store = new onlineStorePlatformEntities())
                {
                    User userEntry = new User();
                    userEntry.Serialize(userInformation);
                    userEntry.role = userType;
                    store.Users.Add(userEntry);

                    if (userType.Equals(UserContract.TABLE_NORMAL_USER))
                    {
                        NormalUser normalUserEntry = new NormalUser();
                        normalUserEntry.Serialize(userInformation);

                        store.NormalUsers.Add(normalUserEntry);
                        save = true;
                    }
                    else if (userType.Equals(UserContract.TABLE_STORE_OWNER))
                    {
                        StoreOwner storeOwnerEntry = new StoreOwner();
                        storeOwnerEntry.Serialize(userInformation);
                        store.StoreOwners.Add(storeOwnerEntry);
                        save = true;
                    }
                    else if (userType.Equals(UserContract.TABLE_ADMIN) && User.IsInRole(UserContract.TABLE_ADMIN))
                    {
                        Admin adminEntry = new Admin();
                        adminEntry.Serialize(userInformation);
                        store.Admins.Add(adminEntry);
                        save = true;
                    }
                    try
                    {
                        if (save)
                        {
                            store.SaveChanges();
                            return(true);
                        }
                    }
                    catch (DbUpdateException)
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Example #12
0
 //On load παίρνει τις τιμές απο το dataset και τις βάζει στα πεδία και τις τοπικές μεταβλητές .
 private void Profile_Load(object sender, EventArgs e)
 {
     if (x is NormalUser)
     {
         NormalUser nu = (NormalUser)x;
         Id       = nu.GetUserID();
         usrname  = usernamTextBox.Text = nu.GetUserName();
         onoma    = onomaTextBox.Text = nu.GetProfile().GetFirstName();
         lastname = lastnameTextBox.Text = nu.GetProfile().GetLastName();
         email    = emailTextBox.Text = nu.GetProfile().GetEmail();
         dob      = dobPicker.Value = nu.GetProfile().GetDob();
         adress   = adressTextBox.Text = nu.GetProfile().GetAddress();
     }
 }
Example #13
0
        private void addUserAccount(string fn, string ln, string un, string em, string ps, string cp)
        {
            NormalUser n;

            n          = new NormalUser();
            n.Fname    = fn;
            n.Lname    = ln;
            n.Username = un;
            n.Email    = em;
            n.Passwd   = ps;
            n.Conpass  = cp;

            acc.Add(n);
        }
Example #14
0
 public ActionResult UpdateUserProfile(NormalUser normalUser)
 {
     if (normalUser.id == null)
     {
         context.NormalUsers.Add(normalUser);
     }
     else
     {
         var userInDb = context.NormalUsers.Single(c => c.id == normalUser.id);
         userInDb.name       = normalUser.name;
         userInDb.bloodGroup = normalUser.bloodGroup;
     }
     context.SaveChanges();
     return(RedirectToAction("UserProfile", "User", new { id = User.Identity.GetUserId() }));
 }
Example #15
0
        // Controleert de input van het 'Form'. Indien de input valide is,
        // wordt de nieuwe gebruiker toegevoegd aan de database. Anders
        // wordt een toepasselijke foutmelding getoond
        protected void btnSignup_Click(object sender, EventArgs e)
        {
            int temp;

            if (tbxDay.Text == "" || tbxMonth.Text == "" || tbxYear.Text == "")
            {
                errorLabel.Text = "Please Enter Your Birthday";
            }
            else if (!Int32.TryParse(tbxDay.Text, out temp) ||
                     !Int32.TryParse(tbxMonth.Text, out temp) ||
                     !Int32.TryParse(tbxYear.Text, out temp))
            {
                errorLabel.Text = "Invalid Date of Birth";
            }
            else
            {
                string name     = tbxInputUsername.Text;
                string password = tbxInputPassword.Text;
                string email    = tbxInputEmail.Text;
                Region region   = null;
                foreach (Region r in admin.Regions)
                {
                    if (r.Name == ddlRegion.SelectedValue)
                    {
                        region = r;
                        break;
                    }
                }
                DateTime dob = new DateTime(Convert.ToInt32(tbxYear.Text),
                                            Convert.ToInt32(tbxMonth.Text),
                                            Convert.ToInt32(tbxDay.Text));
                bool       newsletter = cbxNews.Checked;
                NormalUser user       = new NormalUser(name, password, email, region, dob, newsletter);
                if (!admin.AddUser(user))
                {
                    errorLabel.Text       = "Username is already taken";
                    tbxInputUsername.Text = "";
                    return;
                }
                Response.Redirect("SignUp.aspx?success");
                //tbxInputUsername.Text = "";
                //tbxInputPassword.Text = "";
                //tbxInputEmail.Text = "";
                //tbxDay.Text = "";
                //tbxMonth.Text = "";
                //tbxYear.Text = "";
            }
        }
Example #16
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    if (model.RoleName == "User")
                    {
                        var normalUser = new NormalUser
                        {
                            id = user.Id
                        };
                        context.NormalUsers.Add(normalUser);
                        context.SaveChanges();
                    }
                    else if (model.RoleName == "Doctor")
                    {
                        var doctor = new Doctor
                        {
                            id = user.Id
                        };
                        context.Doctors.Add(doctor);
                        context.SaveChanges();
                    }
                    result = await UserManager.AddToRoleAsync(user.Id, model.RoleName);

                    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>");

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

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #17
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var        db = HttpContext.GetOwinContext().Get <ApplicationDbContext>();
                Cathedral  c  = db.Cathedrals.FirstOrDefault(x => x.Department == model.CathedralName);
                NormalUser nu = db.NormalUsers.FirstOrDefault(x => x.ID == 1);
                if (nu == null)
                {
                    var normalUser = new NormalUser {
                        ID = 1
                    };
                    db.NormalUsers.Add(normalUser);
                    db.SaveChanges();
                    nu = db.NormalUsers.FirstOrDefault(x => x.ID == 1);
                }

                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, FirstName = model.FisrtName, LastName = model.LastName, CathedralID = c, UserConfirmed = false, LockoutEnabled = false, NormalUserID = nu
                };
                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>");

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

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #18
0
        private static void Main(string[] args)
        {
            // Чат.
            var chat = new TextChat();

            // Пользователи.
            var admin         = new Admin(chat, "Adm");
            var normalUserOne = new NormalUser(chat, "AC");
            var normalUserTwo = new NormalUser(chat, "DC");

            // Добавление пользователей в чат.
            chat.Admin = admin;
            chat.AddUserInChat(normalUserOne);
            chat.AddUserInChat(normalUserTwo);

            // Общение.
            normalUserOne.SendMessage("Where is my DC?");
            normalUserTwo.SendMessage("I'm here!!");
            admin.SendMessage("Back in black!");

            Console.ReadKey();
        }
Example #19
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            model.ReturnUrl      = model.ReturnUrl ?? Url.Content("~/");
            model.ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new NormalUser {
                    UserName    = model.Email, Email = model.Email,
                    PhoneNumber = model.PhoneNumber, FirstName = model.FirstName, LastName = model.LastName, Adress = model.Adress
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    //var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
                    //code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    //var callbackUrl = Url.Action(
                    //    "ConfirmEmail","Account", new { userId = user.Id, code = code},
                    //    protocol: Request.Scheme, Request.Host.ToString());

                    //await _emailSender.SendEmailAsync(model.Email, "Confirm your email",
                    //   $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
                    //var mailsender = new MailSender(_config);
                    //mailsender.Send(new List<MailMessage>
                    //{
                    //    new MailMessage
                    //    {
                    //        Body=callbackUrl,
                    //        Receiver=model.Email,
                    //        Sender="*****@*****.**",
                    //        SenderName="Arman",
                    //        Subject="Confirm your email"
                    //    }
                    //});

                    //if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    //{
                    //    return RedirectToAction("Login","Account");
                    //}
                    //else
                    //{

                    //}

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(model.ReturnUrl));


                    //await _emailSender.SendEmailAsync(model.Email, "Confirm your email",
                    //        $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    //await _signInManager.SignInAsync(user, isPersistent: false);
                    //return LocalRedirect(model.ReturnUrl);
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #20
0
        private void Syndesi_Click(object sender, EventArgs e)
        {
            loginfail.Visible = false;
            if (AllCheck() == true)
            {
                //kane eisodo
                User_Classes.Visitor vis = new User_Classes.Visitor();
                String username          = UsernameLog.Text;
                String password          = PasswordLog.Text;

                try
                {
                    //try gia na dei ean einai normaluser
                    Cursor.Current = Cursors.WaitCursor;
                    vis.LogInAsNormalUser(username, password);
                    NormalUser nu = (NormalUser)InstanceOfUser.GetUser();
                    MessageBox.Show(nu.GetUserID().ToString());
                    Cursor.Current = Cursors.Default;
                    if (MessageBox.Show("Είσοδος στον λογαριασμό σας!", "OK", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                    {
                        Control parent = this.Parent;
                        while (parent.Name != "Form1")
                        {
                            Debug.WriteLine(parent.Name);
                            parent = parent.Parent;
                        }

                        foreach (Control c in parent.Controls)
                        {
                            if (c.Name == "homepagePanel")
                            {
                                parent = c;
                            }
                        }

                        switch (parent.Controls["button8"].Text)
                        {
                        case "LOGIN":
                            parent.Controls["button8"].Text             = "LOGOUT";
                            parent.Controls["button7"].Visible          = false;
                            parent.Controls["cCircularbutton1"].Visible = true;
                            break;
                        }

                        Controls.Clear();
                        Controls.Add(new HomeMain());
                    }
                }
                catch (User_Classes.Exceptions.FailLogInAsNormalUser msg)
                {//ean den einainormaluser ,try ean einai eventmanager
                    try
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        vis.LogInAsEventManager(username, password);
                        Cursor.Current = Cursors.Default;
                        if (MessageBox.Show("Είσοδος στον λογαριασμό σας!", "OK", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                        {
                            Control parent = this.Parent;
                            while (parent.Name != "Form1")
                            {
                                Debug.WriteLine(parent.Name);
                                parent = parent.Parent;
                            }

                            foreach (Control c in parent.Controls)
                            {
                                if (c.Name == "homepagePanel")
                                {
                                    parent = c;
                                }
                            }
                            switch (parent.Controls["button8"].Text)
                            {
                            case "LOGIN":
                                parent.Controls["button8"].Text             = "LOGOUT";
                                parent.Controls["button7"].Visible          = false;
                                parent.Controls["cCircularbutton1"].Visible = true;
                                break;
                            }

                            Controls.Clear();
                            Controls.Add(new HomeMain());
                        }
                    }
                    catch (User_Classes.Exceptions.FailLoginAsEventManager msg1)
                    {//ean den einai emfanizei minma lathous
                        Cursor.Current    = Cursors.Default;
                        messagelabel.Text = msg1.ToString();
                        loginfail.Visible = true;

                        UsernameLog.ForeColor = System.Drawing.Color.Gray;
                        UsernameLog.Text      = "Username";
                        PasswordLog.ForeColor = System.Drawing.Color.Gray;
                        PasswordLog.Text      = "Κωδικός";
                    }
                }
            }
        }