public Boolean addUserDetail(User_Detail userDetail)
        {
            Boolean status = false;


            try
            {
                using (var db = new ModelDB())
                {
                    string passencripted = EncryptionUtil.ToSHA256(userDetail.password);
                    Console.WriteLine(passencripted);
                    userDetail.password = passencripted;
                    db.User_Detail.Add(userDetail);
                    db.SaveChanges();
                    status = true;
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var entityValidationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in entityValidationErrors.ValidationErrors)
                    {
                        Console.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }
            return(status);
        }
        public Boolean checkUserLogin(string username, string password)
        {
            Console.Write("username " + username + " password " + password);

            string encrypted = EncryptionUtil.ToSHA256(password);

            Console.Write("encrypted " + encrypted);

            User_Detail userdetail  = null;
            Boolean     user_status = false;

            try
            {
                using (var db = new ModelDB())
                {
                    Console.Write("user detail" + db.User_Detail.FirstOrDefault());
                    userdetail = db.User_Detail.Where(u => u.user_name == username && u.password == encrypted).FirstOrDefault();
                    Console.Write("user detail " + userdetail);
                    if (userdetail != null)
                    {
                        user_status = true;
                    }
                }
            }
            catch (InvalidOperationException ex)
            {
                Console.Write(ex.StackTrace);
            }

            return(user_status);
        }
Example #3
0
 public ActionResult Registration(User_Detail userModel)
 {
     using (SpeckleDB speckleDB = new SpeckleDB())
     {
         speckleDB.Users.Add(userModel);
         speckleDB.SaveChanges();
     }
     ModelState.Clear();
     ViewBag.SuccessMessage = "Registration Successful.";
     return(View("Registration", new User_Detail()));
 }
Example #4
0
 public void update(User_Detail given_User_Detail)
 {
     this.Text = given_User_Detail.username;
     label_Name_User_Display_Form.Text     = given_User_Detail.username;
     label_Password_User_Display_Form.Text = crypting_Object.DecryptString(given_User_Detail.encrypted_General_Password);
     label_Phone_No_User_Display_Form.Text = given_User_Detail.phone_No;
     label_Email_Id_User_Display_Form.Text = given_User_Detail.mail_Id;
     label_Type_User_Display_Form.Text     = given_User_Detail.type;
     if (given_User_Detail.image_Path != "")
     {
         pictureBox_User_Form.Load(given_User_Detail.image_Path);
     }
 }
Example #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["idKhachHang"] == null)
     {
         AvatarKhachHang.ImageUrl = "./img/mèo bó chịu.jpg";
         NameKhachHang.Text       = "Đụt Team";
     }
     else
     {
         int idKhachHang             = Convert.ToInt32(Session["idKhachHang"]);
         Managerment_PageEntities db = new Managerment_PageEntities();
         User_Detail user            = db.User_Detail.FirstOrDefault(x => x.idAccount == idKhachHang);
         AvatarKhachHang.ImageUrl = "./img/customer/" + user.imgAccount;
         NameKhachHang.Text       = user.fullname;
     }
 }
        public async Task <IActionResult> Create([Bind("Somatotyp,Aim,Height,Sex,Activity")] User_Detail user_Detail)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    user_Detail.Id = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                    _context_UserDetail.Add_User_Detail(user_Detail);
                    await _context_UserDetail.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
            return(View(user_Detail));
        }
Example #7
0
        void settings_Click(object sender, EventArgs e)
        {
            User_Detail   temp_User_Detail   = db_Connect.get_User_Details_For_This_User(username, company_Name);
            Form_Settings temp_Form_Settings = new Form_Settings("Gmail", "", "", crypting_Object.DecryptString(temp_User_Detail.encrypted_General_Password));

            temp_Form_Settings.button_Cancel_Settings_Form.Click += new EventHandler((sender_1, evt_1) => {
                Form_Settings temp_Form = (Form_Settings)((Button)(sender_1)).Parent;
                temp_Form.Hide();
            });
            temp_Form_Settings.button_Ok_Settings_Form.Click += new EventHandler((sender_2, evt_2) =>
            {
                Form_Settings temp_Form = (Form_Settings)((Button)(sender_2)).Parent;
                db_Connect.update_Settings_For_This_User(username, company_Name,
                                                         temp_Form.textBox_Mail_Id.Text,
                                                         crypting_Object.EncryptToString(temp_Form.textBox_Mail_Password.Text),
                                                         crypting_Object.EncryptToString(temp_Form.textBox_General_Password.Text));
                temp_Form.Hide();
            });
            temp_Form_Settings.ShowDialog();
        }
Example #8
0
        public async Task <ActionResult> Create(CreateUserViewModel model, Dictionary <string, string> customfield)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                if (customfield != null)
                {
                    foreach (var obj in customfield)
                    {
                        var detail = new User_Detail
                        {
                            Name  = obj.Key,
                            Value = obj.Value,
                        };
                        user.Details.Add(detail);
                    }
                }
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    if (model.RoleList.Count() > 0)
                    {
                        result = await UserManager.AddToRolesAsync(user.Id, model.RoleList);
                    }

                    if (result.Succeeded)
                    {
                        return(RedirectToAction("List"));
                    }
                }
                AddErrors(result);
            }
            ViewData[ROLES]         = Getroles();
            ViewData[CUSTOM_FIELDS] = GetCustomFields();
            return(View(model));
        }
Example #9
0
        public User_Form(string given_Action, User_Detail given_User_Detail)
        {
            InitializeComponent();
            crypting_Object = new Useful_Functions.SimpleAES();
            button_Add_Or_Update_User_Form.Text = given_Action;
            if (given_Action == "Update")
            {
                textBox_Name_User_Form.ReadOnly = true;
            }
            user_Detail = given_User_Detail;

            if (user_Detail != null)
            {
                textBox_Name_User_Form.Text     = user_Detail.username;
                textBox_Password_User_Form.Text = crypting_Object.DecryptString(user_Detail.encrypted_General_Password);
                textBox_Email_Id_User_Form.Text = user_Detail.mail_Id;

                textBox_Phone_No_User_Form.Text = user_Detail.phone_No;
                comboBox_Type_User_Form.Text    = user_Detail.type;
                pictureBox_User_Form.Load(user_Detail.image_Path);
                textBox_Browse_User_Form.Text = user_Detail.image_Path;
            }
        }
Example #10
0
 /// <summary>
 /// 设置用户信息
 /// </summary>
 /// <param name="model"></param>
 public void SetUser(User_Detail model)
 {
     RedisHelper.Set(RedisKey + model.UserId, model);
 }
Example #11
0
 public void UpdateUserDetail(User_Detail detail) => _db.Update(detail);
Example #12
0
 public void Add_User_Detail(User_Detail user_Detail) => _db.User_Details.Add(user_Detail);
Example #13
0
        public ActionResult Registration(int id = 0)
        {
            User_Detail userModel = new User_Detail();

            return(View(userModel));
        }