Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            UserManager userManager = new UserManager();

            bool isCorrect = userManager.CheckCredentials(txtUsername.Text, txtUserpass.Text, data.Users);

            if (isCorrect)
            {
                AppUser currentUser = userManager.FindByUsername(txtUsername.Text, data);

                if (currentUser != null)
                {
                    data.CurrentUser = currentUser;

                    if (currentUser.IsAdmin)
                    {
                        AdminForm adminForm = new AdminForm(this);
                        adminForm.Show();
                        this.Hide();
                    }
                    else
                    {
                        AppUserForm appUserForm = new AppUserForm(this);
                        appUserForm.Show();
                        this.Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show("Giriş başarısız", ":(", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public async Task <ActionResult <ApiResponse <AppUserModel> > > UpdateUserProfile([FromForm] AppUserForm form)
        {
            if (string.IsNullOrEmpty(form.email) || string.IsNullOrEmpty(form.fullName) || string.IsNullOrEmpty(form.mobile))
            {
                return(new ApiResponse <AppUserModel> {
                    code = 0, message = "Null Values"
                });
            }
            var appUser = await _context.AppUsers.FindAsync(_repos.mobile);

            if (form.profileImage.Length > 0)
            {
                if (appUser.dpPath != "/images/profile-picture/default.png")
                {
                    await _storage.DeleteIfExists(appUser.dpPath);
                }

                string dpPath = await _storage.Save(form.profileImage, "/profile-picture", form.Profileextension);

                appUser.dpPath = dpPath;
            }
            if (form.aadharcard.Length > 0)
            {
                if (appUser.AadharCard != "/images/profile-picture/default.png")
                {
                    await _storage.DeleteIfExists(appUser.AadharCard);
                }
                string straadharCard = await _storage.Save(form.aadharcard, "/profile-picture", form.aadharcardextension);

                appUser.AadharCard = straadharCard;
            }
            if (form.pancard.Length > 0)
            {
                if (appUser.PanCard != "/images/profile-picture/default.png")
                {
                    await _storage.DeleteIfExists(appUser.PanCard);
                }
                //appUser.PanCard = await _storage.Save(form.pancard, "/profile-picture");

                string strPanCard = await _storage.Save(form.pancard, "/profile-picture", form.pancardextension);

                appUser.PanCard = strPanCard;
            }

            appUser.fullName    = form.fullName;
            appUser.company     = form.company;
            appUser.email       = form.email;
            appUser.stateID     = form.stateID;
            appUser.cityID      = form.cityID;
            appUser.Address     = form.Address;
            appUser.countryID   = form.countryID;
            appUser.gender      = form.gender;
            appUser.pincode     = form.pincode;
            appUser.dateOfBirth = form.dateOfBirth;


            _context.Entry(appUser).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(new ApiResponse <AppUserModel> {
                    code = 0, message = "Error"
                });
            }
            return(new ApiResponse <AppUserModel> {
                code = 1, message = "Success"
            });
        }