Beispiel #1
0
        public tbl_tenant CreateTenant(string tenantkey, string tenantname, int tenanttype, string contactperson,
                                       string email, string contactno, string altcontactno, string password, int[] roles, DateTime accountvalidtill)
        {
            var existingTenant = _tenantRepository.GetSingleByTenantKey(tenantkey);

            if (existingTenant != null)
            {
                throw new Exception("Tenant is already registered!");
            }

            var passwordSalt = _encryptionService.CreateSalt();

            var newtenant = new tbl_tenant()
            {
                tenant_key         = tenantkey,
                tenant_name        = tenantname,
                tenant_type        = tenanttype,
                contact_person     = contactperson,
                email              = email,
                contact_no         = contactno,
                alt_contact_no     = altcontactno,
                IsLocked           = false,
                account_valid_till = accountvalidtill,
                date_created       = DateTime.Now,
                created_by         = 1,
                date_modified      = DateTime.Now,
                modified_by        = 1
            };

            var newuser = new tbl_user()
            {
                userid        = tenantkey,
                user_name     = tenantname,
                salt          = passwordSalt,
                email         = email,
                is_locked     = false,
                is_tenant     = true,
                password      = _encryptionService.EncryptPassword(password, passwordSalt),
                date_created  = DateTime.Now,
                date_modified = DateTime.Now
            };



            _tenantRepository.Add(newtenant);
            _userRepository.Add(newuser);

            _unitOfWork.Commit();

            if (roles != null || roles.Length > 0)
            {
                foreach (var role in roles)
                {
                    addUserToRole(newuser, role);
                }
            }
            _unitOfWork.Commit();

            return(newtenant);
        }
        public ActionResult SignUp(tbl_user uvm, HttpPostedFileBase imgfile)
        {
            Password EncryptData = new Password();



            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                tbl_user u = new tbl_user();
                u.u_name  = uvm.u_name;
                u.u_email = uvm.u_email;
                //u.u_password = uvm.u_password;
                u.u_password = EncryptData.Encode(uvm.u_password);
                u.cat_image  = path;
                u.u_contact  = uvm.u_contact;

                db.tbl_user.Add(u);
                db.SaveChanges();
                return(RedirectToAction("Login"));
            }

            return(View());
        } //method......................... end.....................
        public bool updateaccessleveltouser(int userid)
        {
            tbl_user user = db.tbl_user.Find(userid);


            foreach (var item in db.tbl_actions)
            {
                var qaccessnew = db.tbl_actionaccessibility.Where(a => a.userid == userid && a.acction_id == item.id).SingleOrDefault();
                if (qaccessnew == null)
                {
                    tbl_actionaccessibility t = new tbl_actionaccessibility();
                    if (item.id == 97 || item.id == 98 || item.id == 27)
                    {
                        t.acction_id = item.id;
                        t.userid     = userid;
                        t.permission = true;
                        db.tbl_actionaccessibility.Add(t);
                    }
                    else
                    {
                        t.acction_id = item.id;
                        t.userid     = userid;
                        t.permission = false;
                        db.tbl_actionaccessibility.Add(t);
                    }
                }
                ;
            }
            db.SaveChanges();

            return(true);
        }
        public HttpResponseMessage changePWD(HttpRequestMessage request, LoginViewModel user)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, new { success = false });
                }
                else
                {
                    tbl_user _user = _membershipService.ChangePassword(user.userid, user.oldpassword, user.password);

                    if (_user != null)
                    {
                        response = request.CreateResponse(HttpStatusCode.OK, new { success = true });
                    }
                    else
                    {
                        response = request.CreateResponse(HttpStatusCode.OK, new { success = false });
                    }
                }

                return response;
            }));
        }
Beispiel #5
0
 public ActionResult Create([Bind(Include = "fld_idUser,fld_username,fld_encryptedPassword,fld_password,fk_idTipo")] tbl_user tbl_user)
 {
     if (ModelState.IsValid && tbl_user.fld_encryptedPassword.Equals(tbl_user.fld_password))
     {
         try
         {
             tbl_user.fk_idTipo = 2;
             Helper.ValidatePassword(tbl_user.fld_password);
             Helper.ValidatePassword(tbl_user.fld_encryptedPassword);
             tbl_user.fld_encryptedPassword = Helper.Encrypt(tbl_user.fld_password);
             db.tbl_user.Add(tbl_user);
             db.SaveChanges();
             TempData["mensaje"] = "Se ha registrado de forma exitosa. Ahora puede iniciar sesión";
             TempData["estado"]  = "ok";
         }
         catch (ValidatorException ex) {
             TempData["mensaje"] = ex.Message;
             TempData["estado"]  = "fail";
         }
     }
     else
     {
         TempData["mensaje"] = "Las contraseñas no coinciden";
         TempData["estado"]  = "fail";
     }
     return(RedirectToAction("Create", "User"));
 }
        private string CreateJWT(tbl_user user)
        {
            var secretKey = configuration.GetSection("AppSettings:Key").Value;
            var key       = new SymmetricSecurityKey(Encoding.UTF8.
                                                     GetBytes(secretKey));

            var claims = new Claim[] {
                new Claim(ClaimTypes.Name, user.user_name),
                new Claim(ClaimTypes.NameIdentifier, user.id.ToString())
            };

            var signingCredentials = new SigningCredentials(key,
                                                            SecurityAlgorithms.HmacSha256Signature);

            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(claims),
                Expires            = DateTime.UtcNow.AddMinutes(1),
                SigningCredentials = signingCredentials,
            };

            var tokenHandler = new JwtSecurityTokenHandler();
            var token        = tokenHandler.CreateToken(tokenDescriptor);

            return(tokenHandler.WriteToken(token));
        }
Beispiel #7
0
 public void Update(tbl_user user)
 {
     db.Entry(user).State = EntityState.Modified;
     db.Configuration.ValidateOnSaveEnabled = false;
     Save();
     db.Configuration.ValidateOnSaveEnabled = true;
 }
Beispiel #8
0
    // UPDATE PASSWORD
    public void newPass(tbl_user p_pass)
    {
        // find row to update
        var query =
            from f in dc.tbl_users
            where f.user_tiwtter == p_pass.user_tiwtter
            select f;

        List<tbl_user> x = query.ToList();

        //update

        foreach (tbl_user person in query)
        {
            person.user_password = p_pass.user_password;
        }

        try
        {
            dc.SubmitChanges();
        }

        catch (Exception e)
        {
            Console.WriteLine(e);
            // Provide for exceptions.
        }
    }
Beispiel #9
0
        public ActionResult Edit(int id, tbl_user user)
        {
            try
            {
                var olduser = db.tbl_user.SingleOrDefault(x => x.userID == id);
                if (olduser != null)
                {
                    olduser.userName        = user.userName;
                    olduser.userPassword    = user.userPassword;
                    olduser.userDisplayName = user.userDisplayName;
                    olduser.userCellNumber  = user.userCellNumber;
                    olduser.userRole        = user.userRole;
                    olduser.BID             = user.BID;
                    olduser.CID             = user.CID;

                    db.SaveChanges();
                    return(Json("success", JsonRequestBehavior.AllowGet));
                }


                return(Json("user not found", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #10
0
        public tbl_user getUserInfo(string openId)
        {
            SqlSugarClient db   = SqlSugarInstance.newInstance();
            tbl_user       user = db.Queryable <tbl_user>().Where(o => o.openid == openId).First();

            return(user);
        }
        public ActionResult login(tbl_user tbl_User)
        {
            if (ModelState.IsValid)
            {
                using (IT_ASSET_MANAGEMENTEntities db = new IT_ASSET_MANAGEMENTEntities())
                {
                    var obj = db.tbl_user.Where(User => User.USER_NO.Equals(tbl_User.USER_NO) && User.USER_PASSWORD.Equals(tbl_User.USER_PASSWORD)).FirstOrDefault();

                    if (obj != null)
                    {
                        Session["USER_ID"]        = obj.USER_ID.ToString();
                        Session["USER_NO"]        = obj.USER_NO.ToString();
                        Session["USER_NAME"]      = obj.USER_NAME.ToString();
                        Session["NAME_ENG"]       = obj.NAME_ENG.ToString();
                        Session["PROSITION"]      = obj.PROSITION.ToString();
                        Session["DEPARTMENT"]     = obj.DEPARTMENT.ToString();
                        Session["USER_EMAIL"]     = obj.USER_EMAIL.ToString();
                        Session["USER_EXTENSION"] = obj.USER_EXTENSION.ToString();
                        Session["USER_ROLE"]      = obj.USER_ROLE.ToString();



                        return(RedirectToAction("Index", "tbl_Req_AF"));
                    }

                    else
                    {
                        ViewBag.Message = " Username or Password is not correct";
                    }
                }
            }
            return(View(tbl_User));
        }
Beispiel #12
0
        public tbl_user getUser(string userid)
        {
            SqlSugarClient db     = SqlSugarInstance.newInstance();
            tbl_user       result = db.Queryable <tbl_user>().Where(o => o.openid == userid).First();

            return(result);
        }
Beispiel #13
0
        public tbl_user getRobotUser()
        {
            SqlSugarClient db   = SqlSugarInstance.newInstance();
            tbl_user       user = db.Queryable <tbl_user>().Where(o => o.ifRobot == 1).OrderBy(o => getRand()).First();

            return(user);
        }
        public ActionResult Login(tbl_user UserObj)
        {
            var user = UserDB_Obj.Login(UserObj);


            if (user > 0)
            {
                FormsAuthentication.SetAuthCookie(UserObj.Email, false);


                //YE LINE USER KA NAME LE KAR NAVBAR MAI DISPLAY KARAY GI AFTER LOGINED

                //VIEW BAG VIEW MAT DETA LAY JATA HAI BUT LAYOUT PAGE MAI NE IS LEYE HAMNE TempData USE KIA HAI

                //seassion variable say jab tak banda rahta hai login data para rtha hai jb k view or tem mai aisa ni


                var obj = UserDB_Obj.GettingUser(UserObj);

                Session["Name"] = obj.Name;

                return(RedirectToAction("Index", "Comman", new { area = "Comman" }));
            }

            //else

            else
            {
                return(View());
            }
        }
Beispiel #15
0
        public ActionResult Viewcontest(int?id)
        {
            Addmodel       ad = new Addmodel();
            tbl_tournament t  = db.tbl_tournament.Where(x => x.t_id == id).SingleOrDefault();

            ad.t_id       = t.t_id;
            ad.t_name     = t.t_name;
            ad.t_image    = t.t_image;
            ad.t_website  = t.t_website;
            ad.t_add      = t.t_add;
            ad.t_contact  = t.t_contact;
            ad.t_dts      = t.t_dts;
            ad.t_dte      = t.t_dte;
            ad.t_cat      = t.t_cat;
            ad.t_fk       = t.t_fk;
            ad.t_prize    = t.t_prize;
            ad.t_desc     = t.t_desc;
            ad.t_location = t.t_location;
            ad.t_entryfee = t.t_entryfee;
            tbl_category cat = db.tbl_category.Where(x => x.c_id == t.t_cat).SingleOrDefault();

            ad.c_name = cat.c_name;
            tbl_user user = db.tbl_user.Where(x => x.u_id == t.t_fk).SingleOrDefault();

            ad.u_name  = user.u_name;
            ad.u_img   = user.u_img;
            ad.u_desc  = user.u_desc;
            ad.u_email = user.u_email;
            ad.t_fk    = user.u_id;
            //var list = ad.ToList();
            return(View(ad));
        }
Beispiel #16
0
        public object UpdateGrievanceAllocation(GrievanceAllocationParam PR)
        {
            try
            {
                tbl_member obGR = db.tbl_member.Where(r => r.UserId == PR.UserId).FirstOrDefault();

                obGR.griType       = PR.griType;
                obGR.designation   = PR.designation;
                obGR.modified_date = DateTime.Now;
                //db.tbl_user.Add(objuser);
                db.SaveChanges();

                tbl_grievance_list objgrlist = db.tbl_grievance_list.Where(r => r.grivance_name == PR.griType).FirstOrDefault();
                objgrlist.Isalloted = 1;
                db.SaveChanges();

                tbl_user objuser = db.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault();
                objuser.name    = PR.name;
                objuser.code    = PR.code;
                objuser.email   = PR.email;
                objuser.contact = PR.contact;
                db.SaveChanges();
                return(new Result()
                {
                    IsSucess = true, ResultData = "Grievance Update Successfully."
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        /// <summary>
        /// judge the id and passwd wheather correct
        ///
        /// 1. query the id passwd
        /// 2. id exists
        /// 3. passws whether correct
        /// </summary>
        /// <param name="ID">input ID</param>
        /// <param name="PWD">input password</param>
        /// <returns></returns>
        public static Err login(string ID, string PWD)
        {
            Err e = new Err();

            try
            {
                var db = new DataBase();
                var vu = from data in db.tbl_user
                         where data.U_ID == ID
                         select data;
                //bug: ID exist
                if (vu.Count() == 0)
                {
                    e.res  = false;
                    e.info = "ID not exists";
                    return(e);
                }
                tbl_user u = vu.Single();
                if (PWD == u.U_PWD)
                {
                    return(e);
                }
                else
                {
                    e.res  = false;
                    e.info = "Passwd error";
                }
            }
            catch (Exception ex)
            {
                e.res  = false;
                e.info = ex.Message;
            }
            return(e);
        }
        public IHttpActionResult Posttbl_user(tbl_user tbl_user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tbl_user.Add(tbl_user);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tbl_userExists(tbl_user.Us_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = tbl_user.Us_id }, tbl_user));
        }
Beispiel #19
0
        public object UpdateUser(ParamRegistration PR)
        {
            try
            {
                tbl_user obj = context.tbl_user.Where(r => r.UserId == PR.UserId).FirstOrDefault();

                if (PR.Password == null)
                {
                    obj.name    = PR.Name;
                    obj.email   = PR.Email;
                    obj.contact = PR.Contact;
                    //obj.password = PR.Password;
                }
                else
                {
                    obj.name     = PR.Name;
                    obj.email    = PR.Email;
                    obj.contact  = PR.Contact;
                    obj.password = CryptIt.Encrypt(PR.Password);
                }
                context.SaveChanges();
                return(new Result()
                {
                    IsSucess = true, ResultData = "User Updated Successfully."
                });
            }
            catch (Exception ex)
            {
                return(new Error()
                {
                    IsError = true, Message = ex.Message
                });
            }
        }
        public IHttpActionResult Puttbl_user(string id, tbl_user tbl_user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_user.Us_id)
            {
                return(BadRequest());
            }

            db.Entry(tbl_user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tbl_userExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #21
0
        public void Delete(int Id)
        {
            tbl_user user = db.tbl_user.Find(Id);

            db.tbl_user.Remove(user);
            Save();
        }
Beispiel #22
0
        public ActionResult Login(tbl_user tbl_User)
        {
            if (ModelState.IsValid)
            {
                using (IT_ASSET_MANAGEMENTEntities db = new IT_ASSET_MANAGEMENTEntities())
                {
                    var obj = db.tbl_user.Where(User => User.USER_NO.Equals(tbl_User.USER_NO) && User.USER_PASSWORD.Equals(tbl_User.USER_PASSWORD)).FirstOrDefault();

                    if (obj != null)
                    {
                        Session["USER_ID"]            = obj.USER_ID.ToString();
                        Session["USER_NO"]            = obj.USER_NO.ToString();
                        Session["USER_NAME"]          = obj.USER_NAME.ToString();
                        Session["USER_EMAIL"]         = obj.USER_EMAIL.ToString();
                        Session["USER_EXTENSION"]     = obj.USER_EXTENSION.ToString();
                        Session["USER_ROLE"]          = obj.USER_ROLE.ToString();
                        Session["USER_EMAIL_APPROVE"] = obj.USER_EMAIL_APPROVE.ToString();


                        return(RedirectToAction("Index", "IncStatus"));
                    }
                    else
                    {
                        ViewBag.Message = "LOGIN FAILED!";
                    }
                }
            }
            return(View(tbl_User));
        }
Beispiel #23
0
        public ActionResult SignUp(tbl_user uvm, HttpPostedFileBase imgfile)
        {
            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded";
            }
            else
            {
                tbl_user usr = new tbl_user();
                usr.u_name     = uvm.u_name;
                usr.u_img      = path;
                usr.u_email    = uvm.u_email;
                usr.u_password = uvm.u_password;
                usr.u_dob      = uvm.u_dob;
                usr.u_age      = uvm.u_age;
                usr.u_contact  = uvm.u_contact;
                usr.u_gender   = uvm.u_gender;
                usr.u_desc     = uvm.u_desc;
                db.tbl_user.Add(usr);
                db.SaveChanges();

                return(RedirectToAction("UserLogin"));
            }
            return(View());
        }
    // BUTTON TO CHANGE THE LASTNAME OF THE USER !!!!
    protected void btnChangeLastname_Click(object sender, EventArgs e)
    {
        if (txtLastname.Text != "")
        {
            tbl_user person = new tbl_user();
            BLLChange bllchange = new BLLChange();
            person.user_tiwtter = (string)(System.Web.HttpContext.Current.Session["twitter"]);
            person.user_password = (string)(System.Web.HttpContext.Current.Session["password"]);
            person.user_lastname = txtLastname.Text;

            try
            {
                bllchange.newLast(person);
                lblFeedback2.Text = "Lastname changed!";
                txtLastname.Text = "";
            }

            catch (Exception)
            {
                lblFeedback2.Text = "Something went wrong, try again!";
            }

        }

        else
        {
            lblFeedback2.Text = "Please fill in your new Lastname please!";
        }
    }
Beispiel #25
0
        public ActionResult Edit([Bind(Include = "fld_idUser,fld_username,fld_encryptedPassword,fld_password,fk_idTipo")] tbl_user tbl_user)
        {
            if (Session["username"] == null || Session["idTypeUser"].Equals(2))
            {
                return(Redirect("~/Error/Index"));
            }

            if (ModelState.IsValid && tbl_user.fld_encryptedPassword.Equals(tbl_user.fld_password))
            {
                tbl_user.fk_idTipo = 2;
                Helper.ValidatePassword(tbl_user.fld_password);
                Helper.ValidatePassword(tbl_user.fld_encryptedPassword);
                tbl_user.fld_encryptedPassword = Helper.Encrypt(tbl_user.fld_password);
                db.Entry(tbl_user).State       = EntityState.Modified;
                db.SaveChanges();
                TempData["mensaje"] = "Se han actualizado los datos";
                TempData["estado"]  = "ok";
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["mensaje"] = "Las contraseñas no coinciden";
                TempData["estado"]  = "fail";
            }
            return(View(tbl_user));
        }
        public ActionResult Register(tbl_user u, HttpPostedFileBase imgfile)
        {
            try
            {
                IEnumerable <TBL_MEMBERSHIP> li = db.TBL_MEMBERSHIP.ToList();
                ViewBag.list = new SelectList(li, "MEM_ID", "MEM_TYPE", "select");
                string s = uploadimgfile(imgfile);
                if (s.Equals("-1"))
                {
                    Response.Write("<script>alert('Image Uploading Failed.....')</script>");
                }
                else
                {
                    tbl_user ur = new tbl_user();
                    ur.u_name      = u.u_name;
                    ur.u_email     = u.u_email;
                    ur.u_image     = s;
                    ur.u_contact   = u.u_contact;
                    ur.u_subs      = u.u_subs;
                    ur.u_password  = u.u_password;
                    ur.u_cpassword = u.u_cpassword;
                    db.tbl_user.Add(ur);
                    db.SaveChanges();
                    return(RedirectToAction("AfterSignup"));
                }
            }
            catch (Exception)
            {
            }

            return(View());
        }//Action method end .....
Beispiel #27
0
    protected void btn_add_User_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(User_name.Value.ToString()) && !String.IsNullOrEmpty(User_contact.Value.ToString()))
        {
            bus_dbEntities db = new bus_dbEntities();
            //Create new instance and assign values to columns
            tbl_user user = new tbl_user();

            user.user_name    = User_name.Value.ToString();
            user.user_contact = User_contact.Value.ToString();
            user.user_email   = User_email.Value.ToString();
            user.user_address = User_address.Value.ToString();
            user.fk_type      = Int32.Parse(user_type.SelectedValue.ToString());
            //Add instance in db
            db.tbl_user.Add(user);
            db.SaveChanges();

            List <tbl_user> lgs      = (from x in db.tbl_user select x).ToList();
            var             userType = (from x in db.tbl_usertype select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
            user_type.DataSource     = userType;
            user_type.DataTextField  = "type_name";
            user_type.DataValueField = "type_id";
            user_type.DataBind();
        }
        else
        {
            //Show alert
            ScriptManager.RegisterStartupScript(this, GetType(), "errorAlert", "alert('Please Enter usermane or password');", true);
        }
    }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ObservableCollection <ui_user> custdata;

            custdata = (ObservableCollection <ui_user>)dg_user.DataContext;

            int i = 0;

            foreach (ui_user uu in custdata)
            {
                if (uu.Updata == false)
                {
                    tbl_user user = User.get_single_user(TableBefore[i].ID);
                    user.U_ID    = uu.ID;
                    user.U_PWD   = uu.password;
                    user.U_Power = Convert.ToInt32(uu.power + 1);
                    Err eeee = User.update(user);
                }
                if (uu.Delete == true)
                {
                    User.delete(User.get_single_user(uu.ID));
                }
                i++;
            }
            loadtable();
        }
Beispiel #29
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        // string user = txtUsername.Text;
           // string pw = txtPassword.Text;

           tbl_user user = new tbl_user();
           BLLLogin blllogin = new BLLLogin();
           user.user_tiwtter = txtUsername.Text;
           user.user_password = txtPassword.Text;

            try{
            blllogin.getUser(user);
            lblFeedback.Text = "succes";

            System.Web.HttpContext.Current.Session["twitter"] = txtUsername.Text;
            System.Web.HttpContext.Current.Session["password"] = txtPassword.Text;
            Response.Redirect("Profiles.aspx");

            }

            catch (Exception)
            {
                lblFeedback.Text = "Please try again";
            }
    }
        public object UserLive(StudentParameters obj)
        {
            try
            {
                // var status = db.tbl_user.Where(r => r.code == obj.code && r.type == obj.type).OrderByDescending(r => r.code).ToList();


                tbl_user uobj = db.tbl_user.First(r => r.code == obj.Code && r.type == obj.Type);

                if (uobj.Islive == 0)
                {
                    uobj.Islive = 1;
                }
                else
                {
                    uobj.Islive = 0;
                }


                uobj.code = obj.Code;
                db.SaveChanges();
                return(new Result
                {
                    IsSucess = true,
                    ResultData = "Status Updated!"
                });
            }
            catch (Exception E)
            {
                return(new Error()
                {
                    IsError = true, Message = E.Message
                });
            }
        }
        public ActionResult SignUp(tbl_user reg)
        {
            try
            {
                tbl_user tu = new tbl_user();
                tu.u_name     = reg.u_name;
                tu.u_email    = reg.u_email;
                tu.u_password = reg.u_password;
                tu.u_contact  = reg.u_contact;

                if ((reg.u_name != null) || (reg.u_email != null) || (reg.u_password != null) || (reg.u_contact != null))
                {
                    db.tbl_user.Add(tu);
                    db.SaveChanges();
                    ViewBag.error = "You have been successfully registered";
                }
                else
                {
                    ViewBag.erro = "*Fill all field";
                }
            }

            catch (Exception)
            {
                ViewBag.erro = "Fill all field";
            }
            return(View());
        }
Beispiel #32
0
    public void update(tbl_user d)
    {
        var recordToUpdate = (from user in db.tbl_users where d.user_id
                                  == user.user_id select user).Single();
        recordToUpdate.user_allowed = 1;

        db.SubmitChanges();
    }
Beispiel #33
0
 public void delete(tbl_user d)
 {
     var user = (from u in db.tbl_users
                  where u.user_id == d.user_id
                  select u).Single();
      db.tbl_users.DeleteOnSubmit(user);
      db.SubmitChanges();
 }
Beispiel #34
0
        public void updateSelfIntro(string openId, string selfIntro)
        {
            SqlSugarClient db   = SqlSugarInstance.newInstance();
            tbl_user       user = db.Queryable <tbl_user>().Where(o => o.openid == openId).First();

            user.selfIntro = selfIntro;
            db.Updateable <tbl_user>(user).Where(o => o.openid == openId).ExecuteCommand();
        }
Beispiel #35
0
        public void updateUserStatus(string userId)
        {
            SqlSugarClient db      = SqlSugarInstance.newInstance();
            tbl_user       curUser = db.Queryable <tbl_user>().Where(o => o.openid == userId).First();

            curUser.userStatus = 1;//disable the user
            db.Updateable <tbl_user>(curUser);
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        tbl_user user = new tbl_user();
        usersBLL usersbll = new usersBLL();
        string hash = txtHash.Text;

        try
        {
            //Concateneren van string john_doe... ^JC
            string username = txtFirstName.Text + "_" + txtLastName.Text;
            user.user_firstname = txtFirstName.Text;
            user.user_lastname = txtLastName.Text;
            user.user_password = txtPassword.Text;
            user.user_tiwtter = txtTwitter.Text;
            user.user_picture = "http://joericlaes.be/asp/" + username + ".jpg";
            // een gebruiker mag standaard niet binnen in de gym, wachten op approval(goedkeuring van admin..)^JC
            user.user_allowed = 0;
            //Standaard is een gebruiker newbie... ^JC
            user.fk_function_id = 3;

            SaveImage(hash);
            Upload("ftp://joericlaes.be", "joericlaes", "dqvIQR86", @"C:\asp\" + username + ".jpg");
            usersbll.insert(user);

            //API CALL #1:  Detect face upon registration ^JC
            String request = "http://api.skybiometry.com/fc/faces/detect.json?api_key=605a3798aa464fe494f23dec5f4dad61&api_secret=5ab37fc32a2f441c9bb4abba6aeb33c7&urls=http://joericlaes.be/asp/" + username + ".jpg&attributes=none&detector=agressive";
            var json = new System.Net.WebClient().DownloadString(request);
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            dynamic item = serializer.Deserialize<object>(json);
            dynamic temporaryid = item["photos"][0]["tags"][0]["tid"];

            //API CALL #2:  Save temporary_id to skybiometry database, FACE IS NOT TRAINED YET!!^JC
            String post_tag = "http://api.skybiometry.com/fc/tags/save.json?api_key=605a3798aa464fe494f23dec5f4dad61&api_secret=5ab37fc32a2f441c9bb4abba6aeb33c7&uid=" + username + "@gym_checkin&tids=" + temporaryid;
            var json2 = new System.Net.WebClient().DownloadString(post_tag);

            //API CALL #3:  We are going to train all new faces so they can be recognized ;) ^JC
            String train_faces = "http://api.skybiometry.com/fc/faces/train.json?api_key=605a3798aa464fe494f23dec5f4dad61&api_secret=5ab37fc32a2f441c9bb4abba6aeb33c7&uids=all@gym_checkin";
            var json_train_faces = new System.Net.WebClient().DownloadString(train_faces);
            lblFeedback.Text = "Gebruiker succesvol toegevoegd";

        }
        catch (Exception error)
        {
            lblFeedback.Text = error.InnerException.ToString();
        }
    }
Beispiel #37
0
    public List<tbl_user> getURL(tbl_user gebruiker)
    {
        var query =
            from g in dc.tbl_users
            where g.user_tiwtter == gebruiker.user_tiwtter
            where g.user_password == gebruiker.user_password
            select g;

            return query.ToList();

        /*

                List<BORRIAS_Ticket> x = query.ToList();

                // Execute the query, and change the column values
                // you want to change.
                if (x.Count > 0)
                {
                    foreach (BORRIAS_Ticket ticket in query)
                    {
                        ticket.used = 1;
                    }
                }
                else
                {
                    throw new Exception("Code niet gevonden");
                }
                // Submit the changes to the database.
                try
                {
                    dc.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    // Provide for exceptions.
                }

            }
         */
    }
Beispiel #38
0
    public List<tbl_user> getUser(tbl_user user)
    {
        // Query to find the user
        var query =
           from u in dc.tbl_users
           where u.user_tiwtter == user.user_tiwtter
           where u.user_password == user.user_password
           select u;

        List<tbl_user> x = query.ToList();

        if (x.Count == 0)
        {
            throw new Exception("Twittername or Password is wrong");
        }
        else
        {
            return query.ToList();

        }
    }
    // BUTTON TO CHANGE THE Password OF THE USER !!!!
    protected void btnChangePassword_Click(object sender, EventArgs e)
    {
        if (txtPassword.Text != "")
        {
            if (txtPassword.Text == txtPasswordCheck.Text)
            {

                tbl_user person = new tbl_user();
                BLLChange bllchange = new BLLChange();
                person.user_tiwtter = (string)(System.Web.HttpContext.Current.Session["twitter"]);
                person.user_password = txtPassword.Text;

                try
                {
                    bllchange.newPass(person);
                    lblFeedback2.Text = "Password changed!";
                    txtPassword.Text = "";
                }

                catch (Exception)
                {
                    lblFeedback2.Text = "Something went wrong, try again!";
                }
            }

            else
            {

                lblFeedback2.Text = "The passwords are not the same!";

            }

        }

        else
        {
            lblFeedback2.Text = "Please fill in your new Password please!";
        }
    }
Beispiel #40
0
 public void update(tbl_user d)
 {
     DALusers.update(d);
 }
Beispiel #41
0
 public void insert(tbl_user user)
 {
     daluser.insert(user);
 }
Beispiel #42
0
 // FIRSTNAME
 public void newFirst(tbl_user p_first)
 {
     dalchange.newFirst(p_first);
 }
	private void detach_tbl_users(tbl_user entity)
	{
		this.SendPropertyChanging();
		entity.tbl_function = null;
	}
 partial void Inserttbl_user(tbl_user instance);
 partial void Updatetbl_user(tbl_user instance);
 partial void Deletetbl_user(tbl_user instance);
Beispiel #47
0
 // LASTNAME
 public void newLast(tbl_user p_last)
 {
     dalchange.newLast(p_last);
 }
Beispiel #48
0
 public List<tbl_user> getURL(tbl_user gebruiker)
 {
     return dalprofile.getURL(gebruiker);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // SESSIONS

        if (System.Web.HttpContext.Current.Session["twitter"] == null && System.Web.HttpContext.Current.Session["password"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            var twit = System.Web.HttpContext.Current.Session["twitter"];
            var pasw = System.Web.HttpContext.Current.Session["password"];
        }

        // get userinformation to read out

        tbl_user gebruiker = new tbl_user();
        BLLProfile bllprofile = new BLLProfile();
        gebruiker.user_tiwtter = (string)(System.Web.HttpContext.Current.Session["twitter"]);
        gebruiker.user_password = (string)(System.Web.HttpContext.Current.Session["password"]);

        try
        {
                bllprofile.getURL(gebruiker);
        }

        catch (Exception)
        {

        }
    }
Beispiel #50
0
 public List<tbl_user> getUser(tbl_user user)
 {
     return DALlogin.getUser(user);
 }
Beispiel #51
0
 public void insert(tbl_user user)
 {
     dc.tbl_users.InsertOnSubmit(user);
     dc.SubmitChanges();
 }
Beispiel #52
0
 public void delete(tbl_user d)
 {
     DALusers.delete(d);
 }
Beispiel #53
0
 // TWITTER
 public void newPass(tbl_user p_pass)
 {
     dalchange.newPass(p_pass);
 }