public async Task <ActionResult> Create([Bind(Include = "Id,name,email,address")] tblUsers tblUsers)
        {
            if (ModelState.IsValid)
            {
                db.tblUsers.Add(tblUsers);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(tblUsers));
        }
Exemple #2
0
        public IHttpActionResult PosttblUsers(tblUsers tblUsers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tblUsers.Add(tblUsers);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tblUsers.id }, tblUsers));
        }
Exemple #3
0
        private void Guncelle()
        {
            tblUsers user = db.tblUsers.First(x => x.Id == secimId);

            user.UserName = txtKulAdi.Text;
            user.Sifre    = txtSifre.Text;
            user.Role     = Convert.ToInt32(txtRol.SelectedIndex.ToString());

            db.SaveChanges();
            MessageBox.Show("Güncelleme Yapıldı");
            Listele();
            Temizle();
        }
        public Entities.User GetUse(User oUser)
        {
            try
            {
                tblUsers             otblUsers  = new tblUsers();
                List <tblTask>       listTask   = new List <tblTask>();
                List <Entities.Task> _listTarea = new List <Entities.Task>();

                using (PruebaTecnicaJavierFlorianEntities ctx = new PruebaTecnicaJavierFlorianEntities())
                {
                    otblUsers = ctx.tblUsers.Where(u => u.us_UserName == oUser.userName).FirstOrDefault();

                    if (otblUsers != null)
                    {
                        listTask = ctx.tblTask.Where(o => o.te_UsuarioFk == otblUsers.us_Users_Pk).ToList();

                        oUser.id         = otblUsers.us_Users_Pk.ToString();
                        oUser.nombre     = otblUsers.us_Name;
                        oUser.apellido   = otblUsers.us_LastName;
                        oUser.userName   = otblUsers.us_UserName;
                        oUser.edad       = otblUsers.us_Age.ToString();
                        oUser.estado     = otblUsers.us_Estado.ToString();
                        oUser.crearTarea = otblUsers.us_CreateTask.ToString();

                        if (listTask.Count > 0 && listTask != null)
                        {
                            foreach (var item in listTask)
                            {
                                _listTarea.Add(new Entities.Task()
                                {
                                    id               = item.ta_TareaPk.ToString(),
                                    nombre           = item.ta_Nombre,
                                    descripcion      = item.te_Descripcion,
                                    estado           = item.te_Estado.ToString(),
                                    fechaCreacion    = (item.te_FechaCreacion == null) ? DateTime.Now.ToString() : item.te_FechaCreacion.ToString(),
                                    fechaVencimiento = (item.te_FechaVencimiento == null) ? DateTime.Now.ToString() : item.te_FechaVencimiento.ToString()
                                });
                            }

                            oUser.listTask = _listTarea;
                        }
                    }
                }

                return(oUser);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #5
0
        public IHttpActionResult DeletetblUsers(int id)
        {
            tblUsers tblUsers = db.tblUsers.Find(id);

            if (tblUsers == null)
            {
                return(NotFound());
            }

            db.tblUsers.Remove(tblUsers);
            db.SaveChanges();

            return(Ok(tblUsers));
        }
        public bool AdminIsLoginSuccess(tblUsers userModel)
        {
            var crypto = new SimpleCrypto.PBKDF2();
            var user   = dbModel.tblUsers.Where(x => x.Email == userModel.Email && x.isVerified == true).FirstOrDefault();

            if (user != null)
            {
                if (user.Pswd == crypto.Compute(userModel.Pswd, user.PswdSalt))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #7
0
        // GET: tblStaffs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblUsers tblStaff = db.tblUsers.Find(id);

            if (tblStaff == null)
            {
                return(HttpNotFound());
            }
            return(View(tblStaff));
        }
        public ActionResult DeleteUser(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblUsers userModel = db.tblUsers.Find(id);

            if (userModel == null)
            {
                return(HttpNotFound());
            }
            return(View(userModel));
        }
        // GET: Users/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblUsers tblUsers = await db.tblUsers.FindAsync(id);

            if (tblUsers == null)
            {
                return(HttpNotFound());
            }
            return(View(tblUsers));
        }
        public static tblUsers MapData(Users k)
        {
            tblUsers tk = new tblUsers()
            {
                Email        = k.Email,
                TelNumber    = k.TelNumber,
                UserName     = k.UserName,
                UserPassword = k.UserPassword,
                UserSurname  = k.UserSurname,
                UserID       = k.UserID,
                UserTypeID   = k.UserTypeID
            };

            return(tk);
        }
Exemple #11
0
    protected void setsession(string uname, string pass)
    {
        tblUsers user = new tblUsers();

        user.Where.UserName.Value = uname;
        user.Where.Password.Value = pass;

        user.Query.Load();

        if (user.RowCount > 0)
        {
            UserContext.SetContextItem("userid", user.UserId);
            UserContext.SetContextItem("userlevel", user.UserLevel);
        }
    }
 public ActionResult Login(tblUsers userModel)
 {
     if (new LoginCheck().AdminIsLoginSuccess(userModel))
     {
         var user = db.tblUsers.Where(x => x.Email == userModel.Email).FirstOrDefault();
         Session["adminID"]   = user.Id;
         Session["adminName"] = user.Name;
         return(RedirectToAction("Index", "Admin"));
     }
     else
     {
         ViewBag.LoginErrorMessage = "Hatalı Kullanıcı adı veya şifre";
         return(View("Login", userModel));
     }
 }
Exemple #13
0
        public IPrincipal TryLogIn(UserModel userModel)
        {
            IUserManager userManager = DependencyResolver.Current.GetService <IUserManager>();

            tblUsers user = userManager.GetUserByUsername(userModel.Username);

            if (user != null && user.Password == userModel.Password)
            {
                return(new GenericPrincipal(new GenericIdentity(userModel.Username), new string[] { "user" }));
            }
            else
            {
                return(null);
            }
        }
        public static Users MapData(tblUsers k)
        {
            Users kul = new Users()
            {
                Email        = k.Email,
                TelNumber    = k.TelNumber,
                UserName     = k.UserName,
                UserPassword = k.UserPassword,
                UserSurname  = k.UserSurname,
                UserID       = k.UserID,
                UserTypeID   = k.UserTypeID
                               //tablodakileri sınıflara attık
            };

            return(kul);
        }
        public async Task <List <string> > GetRolesByUserAsync(tblUsers user)
        {
            try
            {
                if (user == null)
                {
                    throw new ArgumentNullException("User cant be null.");
                }

                return((await _UserManager.GetRolesAsync(user)).ToList());
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                return(null);
            }
        }
        public void DeleteUser(User oUser)
        {
            try
            {
                tblUsers otblUsers = new tblUsers();

                using (PruebaTecnicaJavierFlorianEntities ctx = new PruebaTecnicaJavierFlorianEntities())
                {
                    otblUsers           = ctx.tblUsers.Where(u => u.us_UserName == oUser.userName).FirstOrDefault();
                    otblUsers.us_Estado = false;
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #17
0
        public ActionResult ChangePswd(tblUsers userModel)
        {
            var crypto = new SimpleCrypto.PBKDF2();

            if (ModelState.IsValid)
            {
                string encryptedPswd = crypto.Compute(userModel.Pswd);
                userModel.Pswd        = encryptedPswd;
                userModel.ConfirmPswd = encryptedPswd;
                userModel.PswdSalt    = crypto.Salt;

                db.Entry(userModel).State = EntityState.Modified;
                db.SaveChanges();
                return(View());
            }

            return(View());
        }
Exemple #18
0
        public bool InsertUser(tblUsers user)
        {
            bool isSuccesss = true;

            using (DbContext context = this.CreateDbContext())
            {
                try
                {
                    context.Set <tblUsers>().Add(user);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    isSuccesss = false;
                }
            }

            return(isSuccesss);
        }
Exemple #19
0
        private void Ac(int id)
        {
            Temizle();
            edit    = true;
            secimId = id;
            tblUsers user = db.tblUsers.Find(id);

            txtKulAdi.Text = user.UserName;
            txtSifre.Text  = user.Sifre;
            for (int i = 0; i < txtRol.Items.Count; i++)
            {
                if (user.Role == i)
                {
                    txtRol.SelectedIndex = i;
                }
            }
            //txtRol.Text = Convert.ToString(user.Role);

            btnKaydet.Text = "Güncelle";
        }
Exemple #20
0
    bool AuthenticateUser(string username, string password)
    {
        tblUsers user = new tblUsers();

        user.Where.UserName.Value = username;
        user.Where.Password.Value = password;

        user.Query.Load();

        if (user.RowCount > 0)
        {
            UserContext.SetContextItem("userid", user.UserId);
            UserContext.SetContextItem("userlevel", user.UserLevel);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #21
0
        public async Task <IActionResult> OnPostAsync()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(MsgBox.ShowModelStateMsg(ModelState.GetErrors()));
                }

                tblUsers tUser = new tblUsers()
                {
                    UserName       = Input.Email,
                    Email          = Input.Email,
                    Name           = Input.FirstName,
                    Family         = Input.LastName,
                    EmailConfirmed = true
                };

                var result = await _userManager.CreateAsync(tUser, Input.Password);

                if (result.Succeeded)
                {
                    return(MsgBox.ShowSuccessMsg("RefreshPage"));
                }
                else
                {
                    foreach (var item in result.Errors)
                    {
                        ModelState.AddModelError("", item.Description);
                    }

                    return(MsgBox.ShowModelStateMsg(ModelState.GetErrors()));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(MsgBox.ShowErr500Msg());
            }
        }
Exemple #22
0
    private void DoBind()
    {
        int      id   = (int)ViewState["_id"];
        tblUsers user = new tblUsers();

        user.LoadByPrimaryKey(id);

        tbUsername.Text = user.UserName;
        tbPassword.Text = user.Password;

        tbEmail.Text = user.Email;
        if (user.UserLevel == 1)
        {
            ddUserLevel.Visible = false;
            userlevel.Visible   = false;
        }
        else
        {
            ddUserLevel.SelectedValue = user.UserLevel.ToString();
            tbEmail.Text = user.Email;
        }
    }
Exemple #23
0
        public List <tblComments> AddCommentToArticleById(int ArticleID, tblComments comment)
        {
            List <tblComments> comments;

            using (DbContext context = this.CreateDbContext())
            {
                tblUsers    user    = context.Set <tblUsers>().Single(n => n.ID == comment.UserID);
                tblArticles article = context.Set <tblArticles>().Single(n => n.ID == ArticleID);

                comment.tblArticles = article;
                comment.tblUsers    = user;

                context.Set <tblComments>().Add(comment);
                context.SaveChanges();

                comments = context.Set <tblComments>()

                           .Where(n => n.ArticleID == ArticleID)
                           .Include(n => n.tblUsers)
                           .ToList();
            }

            return(comments);
        }
Exemple #24
0
 public ActionResult hesapEkle(tblUsers kullanici)
 {
     db.tblUsers.Add(kullanici);
     db.SaveChanges();
     return(RedirectToAction("index", "Home"));
 }
        public override MembershipUser CreateUser(string username, string password, string email,
            string passwordQuestion, string passwordAnswer, bool isApproved,
            object providerUserKey, out MembershipCreateStatus status)
        {
            if (!SecUtility.ValidateParameter(ref password, true, true, false, 128))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            var salt = GenerateSalt();
            var encodedPassword = EncodePassword(password.ToLowerInvariant(), (int) PasswordFormat, salt);
            if (encodedPassword.Length > 128)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            string encodedPasswordAnswer;

            if (!string.IsNullOrEmpty(passwordAnswer))
            {
                passwordAnswer = passwordAnswer.Trim();
                if (passwordAnswer.Length > 128)
                {
                    status = MembershipCreateStatus.InvalidAnswer;
                    return null;
                }
                encodedPasswordAnswer = EncodePassword(passwordAnswer.ToLowerInvariant(), (int) PasswordFormat, salt);
            }
            else
            {
                encodedPasswordAnswer = passwordAnswer;
            }

            if (!SecUtility.ValidateParameter(ref encodedPasswordAnswer, RequiresQuestionAndAnswer, true, false, 128))
            {
                status = MembershipCreateStatus.InvalidAnswer;
                return null;
            }

            if (!SecUtility.ValidateParameter(ref username, true, true, true, 255))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return null;
            }

            if (!SecUtility.ValidateParameter(ref email, RequiresUniqueEmail, RequiresUniqueEmail, false, 255))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return null;
            }

            if (!SecUtility.ValidateParameter(ref passwordQuestion, RequiresQuestionAndAnswer, true, false, 255))
            {
                status = MembershipCreateStatus.InvalidQuestion;
                return null;
            }

            if (password.Length < MinRequiredPasswordLength)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            var count = 0;

            for (var i = 0; i < password.Length; i++)
            {
                if (!char.IsLetterOrDigit(password, i))
                {
                    count++;
                }
            }

            if (count < MinRequiredNonAlphanumericCharacters)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (PasswordStrengthRegularExpression.Length > 0)
            {
                if (!Regex.IsMatch(password, PasswordStrengthRegularExpression))
                {
                    status = MembershipCreateStatus.InvalidPassword;
                    return null;
                }
            }

            var e = new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(e);

            if (e.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            var context = new MyLifeEntities();
            var user = context.tblUsers.Where(item => item.UserName == username).FirstOrDefault();
            if (user != null)
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return null;
            }

            if (RequiresUniqueEmail)
            {
                user = context.tblUsers.Where(item => item.Email == email).FirstOrDefault();
                if (user != null)
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                    return null;
                }
            }

            user = new tblUsers
                       {
                           UserName = username.ToLowerInvariant(),
                           Password = encodedPassword,
                           PasswordFormat = ((int) PasswordFormat),
                           PasswordSalt = salt,
                           Email = email.ToLowerInvariant(),
                           IsApproved = isApproved,
                           IsLockedOut = false,
                           CreatedDate = DateTime.UtcNow,
                           LastLoginDate = Constants.DateTime.MinSqlDate,
                           LastPasswordChangedDate = Constants.DateTime.MinSqlDate,
                           LastLockoutDate = Constants.DateTime.MinSqlDate
                       };

            try
            {
                context.AddTotblUsers(user);
                context.SaveChanges();
                status = MembershipCreateStatus.Success;
                return Convert(user);
            }
            catch
            {
                status = MembershipCreateStatus.UserRejected;
            }
            return null;
        }
 private MembershipUser Convert(tblUsers obj)
 {
     if (obj == null)
     {
         return null;
     }
     return new MembershipUser(Name, obj.UserName, obj.Id, obj.Email, null, null,
                               obj.IsApproved, obj.IsLockedOut, obj.CreatedDate, obj.LastLoginDate,
                               obj.LastLoginDate, obj.LastPasswordChangedDate, obj.LastLockoutDate);
 }
 public void UpdateUser(tblUsers user)
 {
     context.Entry(user).State = System.Data.Entity.EntityState.Modified;
 }
 /// <summary>
 /// There are no comments for tblUsers in the schema.
 /// </summary>
 public void AddTotblUsers(tblUsers tblUsers)
 {
     base.AddObject("tblUsers", tblUsers);
 }
 public void InsertUser(tblUsers user)
 {
     context.tblUsers.Add(user);
 }
        public void DeleteUser(int userId)
        {
            tblUsers user = context.tblUsers.Find(userId);

            context.tblUsers.Remove(user);
        }
 /// <summary>
 /// Create a new tblUsers object.
 /// </summary>
 /// <param name="id">Initial value of Id.</param>
 /// <param name="userName">Initial value of UserName.</param>
 /// <param name="password">Initial value of Password.</param>
 /// <param name="passwordFormat">Initial value of PasswordFormat.</param>
 /// <param name="passwordSalt">Initial value of PasswordSalt.</param>
 /// <param name="email">Initial value of Email.</param>
 /// <param name="createdDate">Initial value of CreatedDate.</param>
 /// <param name="isApproved">Initial value of IsApproved.</param>
 /// <param name="isLockedOut">Initial value of IsLockedOut.</param>
 /// <param name="lastLoginDate">Initial value of LastLoginDate.</param>
 /// <param name="lastPasswordChangedDate">Initial value of LastPasswordChangedDate.</param>
 /// <param name="lastLockoutDate">Initial value of LastLockoutDate.</param>
 public static tblUsers CreatetblUsers(int id, string userName, string password, int passwordFormat, string passwordSalt, string email, global::System.DateTime createdDate, bool isApproved, bool isLockedOut, global::System.DateTime lastLoginDate, global::System.DateTime lastPasswordChangedDate, global::System.DateTime lastLockoutDate)
 {
     tblUsers tblUsers = new tblUsers();
     tblUsers.Id = id;
     tblUsers.UserName = userName;
     tblUsers.Password = password;
     tblUsers.PasswordFormat = passwordFormat;
     tblUsers.PasswordSalt = passwordSalt;
     tblUsers.Email = email;
     tblUsers.CreatedDate = createdDate;
     tblUsers.IsApproved = isApproved;
     tblUsers.IsLockedOut = isLockedOut;
     tblUsers.LastLoginDate = lastLoginDate;
     tblUsers.LastPasswordChangedDate = lastPasswordChangedDate;
     tblUsers.LastLockoutDate = lastLockoutDate;
     return tblUsers;
 }
        public async Task <OperationResult> AddUserAsync(InpAddUser Input)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Input.Email))
                {
                    throw new ArgumentNullException("Email cant be null.");
                }

                if (string.IsNullOrWhiteSpace(Input.PhoneNumber))
                {
                    throw new ArgumentNullException("PhoneNumber cant be null.");
                }

                if (string.IsNullOrWhiteSpace(Input.FirstName))
                {
                    throw new ArgumentNullException("FirstName cant be null.");
                }

                if (string.IsNullOrWhiteSpace(Input.LastName))
                {
                    throw new ArgumentNullException("LastName cant be null.");
                }

                if (string.IsNullOrWhiteSpace(Input.Password))
                {
                    throw new ArgumentNullException("Password cant be null.");
                }

                tblUsers tUser = new tblUsers()
                {
                    Date          = DateTime.Now,
                    Email         = Input.Email,
                    FirstName     = Input.FirstName,
                    LastName      = Input.LastName,
                    AccessLevelId = Guid.Parse(await _AccesslevelApplication.GetIdByNameAsync("Users")),
                    IsActive      = true,
                    PhoneNumber   = Input.PhoneNumber,
                    UserName      = Input.Email
                };

                var Result = await _UserRepository.CreateUserAsync(tUser, Input.Password);

                if (Result.Succeeded)
                {
                    if (_UserRepository.RequireConfirmedEmail())
                    {
                        return(new OperationResult().Succeeded(1, tUser.Id.ToString()));
                    }
                    else
                    {
                        return(new OperationResult().Succeeded("UserCreatedSuccessfully"));
                    }
                }
                else
                {
                    return(new OperationResult().Failed(string.Join(", ", Result.Errors.Select(a => a.Description))));
                }
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                return(new OperationResult().Failed("Error500"));
            }
        }
Exemple #33
0
        public ActionResult Register()
        {
            tblUsers userModel = new tblUsers();

            return(View(userModel));
        }
Exemple #34
0
        public ActionResult Login()
        {
            tblUsers userModel = new tblUsers();

            return(View(userModel));
        }
Exemple #35
0
    protected void setsession(string uname, string pass)
    {
        tblUsers user = new tblUsers();

        user.Where.UserName.Value = uname;
        user.Where.Password.Value = pass;

        user.Query.Load();

        if (user.RowCount > 0)
        {
            UserContext.SetContextItem("userid", user.UserId);
            UserContext.SetContextItem("userlevel", user.UserLevel);

        }
    }
Exemple #36
0
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     int id = (int)ViewState["_id"];
     tblUsers user = new tblUsers();
     user.LoadByPrimaryKey(id);
     tbPassword.Text = user.Password;
     LinkButton1.Visible = false;
     changepass.Visible = true;
 }
Exemple #37
0
    public void createuser()
    {
        tblUsers user = new tblUsers();
        int id = (int)ViewState["_id"];
        if (id == 0)
        {
            user.AddNew();
        }
        else
        {
            user.LoadByPrimaryKey(id);
        }
        user.UserName = tbUsername.Text;
        if (NewPassword.Text.Length > 0)
        {
            user.Password = NewPassword.Text;
        }
        else
        {
            user.Password = tbPassword.Text;
        }
        user.Email = tbEmail.Text;
        user.UserLevel = int.Parse(ddUserLevel.SelectedValue);

        user.Save();

        // update the page access
        foreach (TableRow tr in Table1.Rows)
        {
            foreach (TableCell tc in tr.Cells)
            {
                try
                {
                    CheckBox cb = (CheckBox)tc.Controls[0];
                    tblUserPageAccess pxl = new tblUserPageAccess();
                    pxl.Where.UserId.Value = user.UserId;
                    pxl.Where.PageXLanguageId.Value = int.Parse(cb.ID);

                    pxl.Query.Load();

                    if (pxl.RowCount == 0)
                    {
                        // new
                        pxl.AddNew();
                        pxl.UserId = user.UserId;
                        pxl.PageXLanguageId = int.Parse(cb.ID);
                    }

                    if (cb.Checked)
                        pxl.AccessLevel = (int)epicCMSLib.epicCMSAccessLevels.CmsUpdate;
                    else
                        pxl.AccessLevel = (int)epicCMSLib.epicCMSAccessLevels.ReadOnly;

                    pxl.Save();
                }
                catch
                {
                }
            }
        }

        // lbJs.Text = "<script type=\"text/javascript\" language=\"javascript\"> function clickButton() { var radWindow = GetRadWindow(); radWindow.Close(); } </script>";
    }
Exemple #38
0
    private void DoBind()
    {
        int id = (int)ViewState["_id"];
        tblUsers user = new tblUsers();
        user.LoadByPrimaryKey(id);

        tbUsername.Text = user.UserName;
        tbPassword.Text = user.Password;

        tbEmail.Text = user.Email;
        if (user.UserLevel == 1)
        {
            ddUserLevel.Visible = false;
            userlevel.Visible = false;
        }
        else
        {
            ddUserLevel.SelectedValue = user.UserLevel.ToString();
            tbEmail.Text = user.Email;
        }
    }
Exemple #39
0
    bool AuthenticateUser(string username, string password)
    {
        tblUsers user = new tblUsers();

        user.Where.UserName.Value = username;
        user.Where.Password.Value = password;

        user.Query.Load();

        if (user.RowCount > 0)
        {
            UserContext.SetContextItem("userid", user.UserId);
            UserContext.SetContextItem("userlevel", user.UserLevel);
            return true;
        }
        else
            return false;
    }