Ejemplo n.º 1
0
        public void managerRegDAL(userEntity userEntityObj)
        {
            using (SqlConnection conObj = new SqlConnection(CS))
            {
                SqlCommand cmdObj = new SqlCommand("managerRegistration", conObj);
                cmdObj.CommandType = CommandType.StoredProcedure;

                cmdObj.Parameters.Clear();
                cmdObj.Parameters.AddWithValue("@usrId", userEntityObj.usrId_);
                cmdObj.Parameters.AddWithValue("@usrName", userEntityObj.usrName_);
                cmdObj.Parameters.AddWithValue("@usrPassword", userEntityObj.usrPassword_);
                cmdObj.Parameters.AddWithValue("@usrEmail", userEntityObj.usrEmail_);
                cmdObj.Parameters.AddWithValue("@usrMobile", userEntityObj.usrMobile_);
                cmdObj.Parameters.AddWithValue("@usrAddress", userEntityObj.usrAddress_);
                cmdObj.Parameters.AddWithValue("@usrType", userEntityObj.usrType_);
                cmdObj.Parameters.AddWithValue("@usrBranchId", userEntityObj.usrBranchId_);
                cmdObj.Parameters.AddWithValue("@usrBranchName", userEntityObj.usrBranchName_);
                cmdObj.Parameters.AddWithValue("@usrBranchCity", userEntityObj.usrBranchCity_);
                cmdObj.Parameters.AddWithValue("@usrBranchLocation", userEntityObj.usrBranchLocation_);
                cmdObj.Parameters.AddWithValue("@usrBranchAddress", userEntityObj.usrBranchAddress_);
                cmdObj.Parameters.AddWithValue("@usrBranchPincode", userEntityObj.usrBranchPincode_);
                cmdObj.Parameters.AddWithValue("@usrSalary", userEntityObj.usrSalary_);
                cmdObj.Parameters.AddWithValue("@usrDoj", userEntityObj.usrDoj_);
                conObj.Open();
                cmdObj.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
0
    protected void btnConsSubmit_Click(object sender, EventArgs e)
    {
        userEntity userEntityObj = new userEntity();

        userEntityObj.usrName_           = txtEmpName.Text.Trim().ToUpper();
        userEntityObj.usrPassword_       = txtEmpPassword.Text.Trim();
        userEntityObj.usrEmail_          = txtEmpEmail.Text.Trim().ToUpper();
        userEntityObj.usrMobile_         = Convert.ToDecimal(txtEmpMobile.Text.Trim());
        userEntityObj.usrAddress_        = txtEmpAddress.Text.Trim().ToUpper();
        userEntityObj.usrType_           = "Employee";
        userEntityObj.usrId_             = "EMP" + txtEmpMobile.Text.Trim();
        userEntityObj.usrBranchId_       = txtBrId.Text.Trim().ToUpper();
        userEntityObj.usrBranchName_     = txtBrName.Text.Trim().ToUpper();
        userEntityObj.usrBranchLocation_ = txtBrLoc.Text.Trim().ToUpper();
        userEntityObj.usrBranchCity_     = txtBrCity.Text.Trim().ToUpper();
        userEntityObj.usrBranchAddress_  = txtBrAddress.Text.Trim().ToUpper();
        userEntityObj.usrBranchPincode_  = Convert.ToDecimal(txtBrPin.Text.Trim());
        userEntityObj.usrRole_           = txtEmpRole.Text.Trim().ToUpper();
        userEntityObj.usrSalary_         = Convert.ToDecimal(txtEmpSal.Text.Trim());
        userEntityObj.usrDoj_            = Convert.ToDateTime(txtEmpDojoin.Text);

        employeeRegistrationBAL employeeRegistrationBALObj = new employeeRegistrationBAL();

        employeeRegistrationBALObj.employeeRegBAL(userEntityObj);
    }
Ejemplo n.º 3
0
        public int userLoginFBAL(userEntity userEntityObj)
        {
            userLoginDAL userLoginDALObj = new userLoginDAL();
            int          usrCountDAL     = Convert.ToInt32(userLoginDALObj.userLoginFDAL(userEntityObj));

            return(usrCountDAL);
        }
        public async Task Put(string id, [FromBody] string value)
        {
            // curl -H "Content-Type: application/json" -d "@TEST.txt" -X PUT https://localhost:5001/api/values/025d3d06-fc2b-4105-a7cb-8600190740e4 --insecure
            // TEST.txt에 숫자만 정상
            userEntity UserEntity = await this._dbContext.userEntitys.FirstOrDefaultAsync(o => o.Id == id).ConfigureAwait(false);

            UserEntity.Detail.Name = value;
            await this._dbContext.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task Delete(string id)
        {
            // curl -H "Content-Type: application/json" -X DELETE https://localhost:5001/api/values/f61c2fb8-48d7-4cc0-8b72-bd4e800480b2 --insecure
            // FK 때문인지 500에러
            userEntity UserEntity = await this._dbContext.userEntitys.FirstOrDefaultAsync(o => o.Id == id).ConfigureAwait(false);

            this._dbContext.userEntitys.Remove(UserEntity);
            await this._dbContext.SaveChangesAsync().ConfigureAwait(false);
        }
Ejemplo n.º 6
0
 void updateUserinfo()
 {
     userEntity user = new userEntity();
      user.Eloginname = this.txtusername.Text;
      user.Epassword = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtpassword.Text, "md5");
      int i = userBll.updateUsermanageP(user, Session["password"].ToString(), Session["username"].ToString());
       if (i > 0)
        {
             js("密码修改成功!");
        }
 }
    public void adminEmpData()
    {
        userEntity userEntityObj = new userEntity();

        userEntityObj.usrType_ = usrType;
        viewEmpAdminBAL viewEmpAdminBALObj = new viewEmpAdminBAL();
        DataSet         dsObj = viewEmpAdminBALObj.viewEmpAdminBALF(userEntityObj);

        GridView1.DataSource = dsObj;
        GridView1.DataBind();
    }
Ejemplo n.º 8
0
 public DataSet viewEmpAdminDALF(userEntity userEntityObj)
 {
     using (SqlConnection conObj = new SqlConnection(CS))
     {
         SqlCommand cmdObj = new SqlCommand("viewEmpAdmin", conObj);
         cmdObj.CommandType = CommandType.StoredProcedure;
         cmdObj.Parameters.AddWithValue("@usrType", userEntityObj.usrType_);
         SqlDataAdapter sdaObj = new SqlDataAdapter(cmdObj);
         DataSet        dsObj  = new DataSet();
         sdaObj.Fill(dsObj);
         return(dsObj);
     }
 }
Ejemplo n.º 9
0
 public int userLoginFDAL(userEntity userEntityObj)
 {
     using (SqlConnection conObj = new SqlConnection(CS))
     {
         SqlCommand cmdObj = new SqlCommand("userLogin", conObj);
         cmdObj.CommandType = CommandType.StoredProcedure;
         cmdObj.Parameters.AddWithValue("@usrEmail", userEntityObj.usrEmail_);
         cmdObj.Parameters.AddWithValue("@usrPassword", userEntityObj.usrPassword_);
         cmdObj.Parameters.AddWithValue("@usrType", userEntityObj.usrType_);
         conObj.Open();
         int usrCount = Convert.ToInt32(cmdObj.ExecuteScalar());
         return(usrCount);
     }
 }
        private void grdUser_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            clear();
            int        id    = ToInt32(grdUser.CurrentRow.Cells["uid"].Value);
            userEntity useer = user.Where(x => x.uid == id).FirstOrDefault();

            txtUserId.Text    = useer.uid.ToString();
            txtUserId.Enabled = false;
            lblid.Text        = useer.Userid.ToString();
            txtUserName.Text  = useer.Username;
            TxtPassword.Text  = useer.Password;
            // ddlRoleId.ResetText();
            ddlRoleId.SelectedIndex = useer.Roleid;
        }
        public void save(UserDto user_dto)
        {
            try
            {
                _transactionManager.beginTransaction();

                if (user_dto.role_ids.Count == 0)
                {
                    throw new InvalidValueException("At least one role must be specified.");
                }

                bool isUsernameValid = checkNameValidity(user_dto);


                if (!isUsernameValid)
                {
                    throw new DuplicateItemException("User with same name already exists.");
                }

                userEntity user = new userEntity();
                _userMaker.copy(user, user_dto);
                user.created_date = DateTime.Now;
                _userRepo.insert(user);

                UserRoleDto userRoleDto = new UserRoleDto()
                {
                    type     = Enums.UserType.user,
                    type_id  = user.user_id,
                    role_ids = user_dto.role_ids.ToArray()
                };

                _userRoleService.save(userRoleDto);

                AuthenticationDto authenticationDto = new AuthenticationDto()
                {
                    username = user_dto.username,
                    password = user_dto.password,
                    type     = Enums.UserType.user,
                    type_id  = user.user_id
                };

                _authenticationService.save(authenticationDto);
                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 12
0
    public void mngEmpData()
    {
        string     usrBranch     = viewMngBranch();
        userEntity userEntityObj = new userEntity();

        userEntityObj.usrType_     = usrType;
        userEntityObj.usrBranchId_ = usrBranch;
        viewEmpAdminBAL viewEmpAdminBALObj = new viewEmpAdminBAL();
        DataSet         dsObj = viewEmpAdminBALObj.viewEmpMngBALF(userEntityObj);

        GridView1.DataSource = dsObj;
        GridView1.DataBind();
        //Label1.Text = usrBranch;
    }
Ejemplo n.º 13
0
    protected void btnSignUp_Click(object sender, EventArgs e)
    {
        userEntity userEntityObj = new userEntity();

        userEntityObj.usrName_     = txtUsrName.Text.Trim().ToUpper();
        userEntityObj.usrPassword_ = txtUsrPassword.Text.Trim();
        userEntityObj.usrEmail_    = txtUsrEmail.Text.Trim().ToUpper();
        userEntityObj.usrMobile_   = Convert.ToDecimal(txtUsrMobile.Text.Trim());
        userEntityObj.usrAddress_  = txtUsrAddress.Text.Trim().ToUpper();
        userEntityObj.usrType_     = "User";
        userEntityObj.usrId_       = "USR" + txtUsrMobile.Text.Trim();

        userRegistrationBAL userRegistrationBALObj = new userRegistrationBAL();

        userRegistrationBALObj.newUserRegBAL(userEntityObj);
    }
        public void update(UserDto user_dto)
        {
            try
            {
                _transactionManager.beginTransaction();
                if (user_dto.role_ids.Count == 0)
                {
                    throw new InvalidValueException("At least one role must be specified.");
                }

                userEntity user = _userRepo.getById(user_dto.user_id) ?? throw new ItemNotFoundException($"User with the id {user_dto.user_id} doesnot exist.");

                bool isUsernameValid = checkNameValidity(user_dto);

                if (!isUsernameValid)
                {
                    throw new DuplicateItemException("User with same name already exists.");
                }

                if (!string.IsNullOrWhiteSpace(user_dto.image_path))
                {
                    if (!string.IsNullOrWhiteSpace(user.image_path))
                    {
                        deleteImage(user.image_path);
                    }
                }

                _userMaker.copy(user, user_dto);
                _userRepo.update(user);
                _userRoleService.update(new UserRoleDto()
                {
                    type     = Enums.UserType.user,
                    type_id  = user.user_id,
                    role_ids = user_dto.role_ids.ToArray()
                });

                _authenticationService.updateUsername(user_dto.username, user_dto.user_id);
                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
    protected void btnConsSubmit_Click(object sender, EventArgs e)
    {
        userEntity userEntityObj = new userEntity();

        userEntityObj.usrName_           = txtMngName.Text.Trim().ToUpper();
        userEntityObj.usrPassword_       = txtMngPassword.Text.Trim();
        userEntityObj.usrEmail_          = txtMngEmail.Text.Trim().ToUpper();
        userEntityObj.usrMobile_         = Convert.ToDecimal(txtMngMobile.Text.Trim());
        userEntityObj.usrAddress_        = txtMngAddress.Text.Trim().ToUpper();
        userEntityObj.usrType_           = "Manager";
        userEntityObj.usrId_             = txtMngId.Text.Trim().ToUpper();
        userEntityObj.usrBranchId_       = "BRN" + txtBrPin.Text.Trim();
        userEntityObj.usrBranchName_     = txtBrName.Text.Trim().ToUpper();
        userEntityObj.usrBranchCity_     = txtBrCity.Text.Trim().ToUpper();
        userEntityObj.usrBranchLocation_ = txtBrLoc.Text.Trim().ToUpper();
        userEntityObj.usrBranchAddress_  = txtBrAddress.Text.Trim().ToUpper();
        userEntityObj.usrBranchPincode_  = Convert.ToDecimal(txtBrPin.Text.Trim());
        userEntityObj.usrSalary_         = Convert.ToDecimal(txtMngSal.Text.Trim());
        userEntityObj.usrDoj_            = Convert.ToDateTime(txtMngDojoin.Text);

        branchEntity branchEntityObj = new branchEntity();

        branchEntityObj.brMngName_        = txtMngName.Text.Trim().ToUpper();
        branchEntityObj.brMngPassword_    = txtMngPassword.Text.Trim();
        branchEntityObj.brMngEmail_       = txtMngEmail.Text.Trim().ToUpper();
        branchEntityObj.brMngMobile_      = Convert.ToDecimal(txtMngMobile.Text.Trim());
        branchEntityObj.brMngAddress_     = txtMngAddress.Text.Trim().ToUpper();
        branchEntityObj.brMngId_          = txtMngId.Text.Trim().ToUpper();
        branchEntityObj.brBranchId_       = "BRN" + txtBrPin.Text.Trim();
        branchEntityObj.brBranchName_     = txtBrName.Text.Trim().ToUpper();
        branchEntityObj.brBranchCity_     = txtBrCity.Text.Trim().ToUpper();
        branchEntityObj.brBranchLocation_ = txtBrLoc.Text.Trim().ToUpper();
        branchEntityObj.brBranchAddress_  = txtBrAddress.Text.Trim().ToUpper();
        branchEntityObj.brBranchPincode_  = Convert.ToDecimal(txtBrPin.Text.Trim());
        branchEntityObj.brMngSalary_      = Convert.ToDecimal(txtMngSal.Text.Trim());
        branchEntityObj.brMngDoj_         = Convert.ToDateTime(txtMngDojoin.Text);

        managerRegistrationBAL managerRegistrationBALObj = new managerRegistrationBAL();

        managerRegistrationBALObj.managerRegBAL(userEntityObj);

        //managerRegistrationBAL managerRegistrationBALObj = new managerRegistrationBAL();
        managerRegistrationBALObj.branchRegBAL(branchEntityObj);
    }
Ejemplo n.º 16
0
 public IHttpActionResult createUser(userEntity usuario)
 {
     try
     {
         Resultado resultado = new BUser().createUser(usuario);
         if (resultado.Respuesta == 1)
         {
             return(Ok(resultado));
         }
         else
         {
             return(BadRequest(resultado.Mensaje));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }
Ejemplo n.º 17
0
        public void newUserRegDAL(userEntity userEntityObj)
        {
            using (SqlConnection conObj = new SqlConnection(CS))
            {
                SqlCommand cmdObj = new SqlCommand("userRegistration", conObj);
                cmdObj.CommandType = CommandType.StoredProcedure;

                cmdObj.Parameters.Clear();
                cmdObj.Parameters.AddWithValue("@usrName", userEntityObj.usrName_);
                cmdObj.Parameters.AddWithValue("@usrPassword", userEntityObj.usrPassword_);
                cmdObj.Parameters.AddWithValue("@usrEmail", userEntityObj.usrEmail_);
                cmdObj.Parameters.AddWithValue("@usrMobile", userEntityObj.usrMobile_);
                cmdObj.Parameters.AddWithValue("@usrAddress", userEntityObj.usrAddress_);
                cmdObj.Parameters.AddWithValue("@usrType", userEntityObj.usrType_);
                cmdObj.Parameters.AddWithValue("@usrId", userEntityObj.usrId_);
                conObj.Open();
                cmdObj.ExecuteNonQuery();
            }
        }
Ejemplo n.º 18
0
        public async Task Post([FromBody] string pw)
        {
            // curl -X POST https://localhost:5001/api/values/ --insecure
            var ue = new userEntity()
            {
                Pw     = pw,
                Detail = new userDetailEntity()
                {
                    Name = "MINSIK", Address = "Seoul"
                },
                Actions = new List <actionEntity>()
                {
                    new actionEntity()
                    {
                        With = "MyFriend"
                    }
                }
            };

            this._dbContext.userEntitys.Add(ue);
            await this._dbContext.SaveChangesAsync().ConfigureAwait(false);
        }
Ejemplo n.º 19
0
        public void managerRegBAL(userEntity userEntityObj)
        {
            managerRegistrationDAL mrdObj = new managerRegistrationDAL();

            mrdObj.managerRegDAL(userEntityObj);
        }
Ejemplo n.º 20
0
        public DataSet viewEmpMngBALF(userEntity userEntityObj)
        {
            viewEmpAdminDAL viewEmpAdminDALObj = new viewEmpAdminDAL();

            return(viewEmpAdminDALObj.viewEmpMngDALF(userEntityObj));
        }
        public void newUserRegBAL(userEntity userEntityObj)
        {
            userRegistrationDAL userRegistrationDALObj = new userRegistrationDAL();

            userRegistrationDALObj.newUserRegDAL(userEntityObj);
        }
        public void employeeRegBAL(userEntity userEntityObj)
        {
            employeeRegistrationDAL employeeRegistrationObj = new employeeRegistrationDAL();

            employeeRegistrationObj.employeeRegDAL(userEntityObj);
        }
Ejemplo n.º 23
0
        public Resultado createUser(userEntity usuario)
        {
            var fotoPerfil = Base64ToImage(usuario.foto_Perfil);
            var passport   = passportNumer();

            while (new DUsuario().validPassportNumber(passport))
            {
                passport = passportNumer();
            }

            usuario newUsuario = new usuario
            {
                usuario1    = usuario.usuario,
                Sexo        = usuario.sexo,
                correo      = usuario.correo,
                telefono    = usuario.telefono,
                password    = usuario.password,
                foto_Perfil = usuario.foto_Perfil,
                id_Pais     = usuario.id_Pais,
                pasaporte   = passport
            };

            try
            {
                var Usuario = new DUsuario().ValidarUsuario(usuario.correo);
                if (Usuario)
                {
                    return(new Resultado()
                    {
                        Respuesta = 0, Mensaje = "El correo que intenta registrar ya se encuentra activo", Valores = null
                    });
                }

                if (fotoPerfil != null)
                {
                    try
                    {
                        int    Id   = new DUsuario().GetLastId();
                        string ruta = CrearCarpeta(Id + 1);
                        if (ruta != "")
                        {
                            bool fotoGuardada = GuardarFoto(ruta, newUsuario.foto_Perfil);
                            if (fotoGuardada)
                            {
                                var          usuarioCreado  = new DUsuario().CreateUsuario(newUsuario, usuario.preferences);
                                LoginResult  loginResult    = new LoginResult();
                                string       updateruta     = @"Resources/Profiles/" + usuarioCreado.id_usuario + @"/foto_perfil.jpg";
                                var          actualizarRuta = new DUsuario().ActualizarRutaFotoUsuario(updateruta, usuarioCreado.correo);
                                LoginRequest login          = new LoginRequest {
                                    email = usuarioCreado.correo, password = usuarioCreado.password
                                };
                                var usuarioToken = new DUsuario().ConsultarUsuario(login);

                                var       tokenJwt = BTokenGenerator.GenerateTokenJwt(usuarioToken);
                                table_jwt jwt      = new table_jwt()
                                {
                                    jwt = tokenJwt
                                };
                                long InsertJwt = new DJwt().CreateJwt(jwt);

                                if (InsertJwt == -1)
                                {
                                    return(new Resultado()
                                    {
                                        Respuesta = 1, Mensaje = "Error generardo token", Valores = null
                                    });
                                }
                                loginResult.jwt = tokenJwt;
                                return(new Resultado()
                                {
                                    Respuesta = 1, Mensaje = "Usuario creado exitosamente", Valores = loginResult
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        return(new Resultado()
                        {
                            Respuesta = 0, Mensaje = "No fue posible guardar la foto, revise que este en el formato correcto Base 64", Valores = null
                        });
                    }
                }
                return(new Resultado()
                {
                    Respuesta = 0, Mensaje = "La foto de perfil debe estar en base 64", Valores = null
                });
            }
            catch (Exception ex)
            {
                return(new Resultado()
                {
                    Respuesta = 0, Mensaje = "Error " + ex, Valores = null
                });
            }
        }