public ActionResult Giris(tbl_users usr)
        {
            string rol = ValidateUser(usr.Login, usr.Sifre);

            if (!string.IsNullOrEmpty(rol))
            {
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                 usr.Login,
                                                                                 DateTime.Now,
                                                                                 DateTime.Now.AddMinutes(15),
                                                                                 true,
                                                                                 rol,
                                                                                 FormsAuthentication.FormsCookiePath);

                HttpCookie cuki = new HttpCookie(FormsAuthentication.FormsCookieName);
                if (ticket.IsPersistent)
                {
                    cuki.Expires = ticket.Expiration;
                }

                Response.Cookies.Add(cuki);
                //Session["rol"] = rol;
                //Response.Redirect(FormsAuthentication.GetRedirectUrl(usr.Login, true));
                FormsAuthentication.RedirectFromLoginPage(usr.Login, true);

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Giris"));
        }
        public ActionResult MuellifOl(tbl_users istfd, string rdqadin, string rdkisi)
        {
            if (!string.IsNullOrEmpty(rdqadin))
            {
                istfd.Cinsi = true;
            }
            if (!string.IsNullOrEmpty(rdkisi))
            {
                istfd.Cinsi = false;
            }
            istfd.QeydiyyatTarixi = DateTime.Now;
            istfd.Yazar           = true;
            istfd.QebulEdildi     = false;
            istfd.Aktiv           = true;
            db.tbl_users.Add(istfd);
            db.SaveChanges();

            tbl_rol     yazar  = db.tbl_rol.FirstOrDefault(x => x.RolAdi == "Yazar");
            tbl_userrol usrrol = new tbl_userrol();

            usrrol.RolId  = yazar.RolId;
            usrrol.UserId = istfd.UserId;
            db.tbl_userrol.Add(usrrol);
            db.SaveChanges();

            return(RedirectToAction("Giris"));
        }
예제 #3
0
        public ActionResult CreateUser(tbl_users t)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (Session["Access"].ToString() != "admin")
            {
                return(RedirectToAction("Index", "Home"));
            }

            t.Date = DateTime.Now;

            db.tbl_users.Add(t);

            if (Convert.ToBoolean(db.SaveChanges()))
            {
                ViewBag.Message = "Seccessfully saved.";
                ViewBag.style   = "color:green;";
                return(View(t));
            }
            else
            {
                ViewBag.Message = "Unfortunately not saved.";
                ViewBag.style   = "color:red;";
                return(View(t));
            }
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_users tbl_users = db.users.Find(id);
            var       user_role = db.users.Where(u => u.username == User.Identity.Name).Select(u => u.tbl_roles.role_name).FirstOrDefault();

            if (tbl_users == null)
            {
                return(HttpNotFound());
            }
            else if (tbl_users.tbl_roles.role_name == "Admin" && user_role != "Super Admin")
            {
                return(new HttpUnauthorizedResult());
            }
            else if (tbl_users.tbl_roles.role_name == "Super Admin")
            {
                return(new HttpUnauthorizedResult());
            }
            if (user_role == "Super Admin")
            {
                ViewBag.Role_id = new SelectList(db.roles.Where(x => x.role_name != "Super Admin"), "Role_Id", "role_name");
            }
            else
            {
                ViewBag.Role_id = new SelectList(db.roles.Where(x => x.role_name != "Super Admin" && x.role_name != "Admin"), "Role_Id", "role_name");
            }
            //ViewBag.Role_id = new SelectList(db.roles.Where(x => x.role_name != "Super Admin"), "Role_Id", "role_name", tbl_users.Role_id);
            return(View(tbl_users));
        }
예제 #5
0
파일: userDAL.cs 프로젝트: x3n0r/teststore
        public userBLL GetIDFromUsername(string username)
        {
            userBLL u = new userBLL();

            try
            {
                var erg = from user in db.tbl_users
                          where user.username == username
                          select user;


                tbl_users myUser = erg.FirstOrDefault();
                if (myUser != null)
                {
                    u.id         = myUser.Id;
                    u.first_name = myUser.first_name;
                    u.last_name  = myUser.last_name;
                    u.email      = myUser.email;
                    u.username   = myUser.username;
                    u.contact    = myUser.contact;
                    u.address    = myUser.address;
                    u.gender     = myUser.gender;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(u);
        }
        private int SekilYukle(HttpPostedFileBase sekil)
        {
            int balacaWidth  = Convert.ToInt32(ConfigurationManager.AppSettings["bw"]);
            int balacaHeight = Convert.ToInt32(ConfigurationManager.AppSettings["bh"]);
            int ortaWidth    = Convert.ToInt32(ConfigurationManager.AppSettings["ow"]);
            int ortaHeight   = Convert.ToInt32(ConfigurationManager.AppSettings["oh"]);
            int boyukWidth   = Convert.ToInt32(ConfigurationManager.AppSettings["bow"]);
            int boyukHeight  = Convert.ToInt32(ConfigurationManager.AppSettings["boh"]);

            string newName   = Path.GetFileNameWithoutExtension(sekil.FileName) + "" + Guid.NewGuid() + Path.GetExtension(sekil.FileName);
            Image  Photo     = Image.FromStream(sekil.InputStream);
            Bitmap balacaSek = new Bitmap(Photo, balacaWidth, balacaHeight);
            Bitmap ortaSek   = new Bitmap(Photo, ortaWidth, ortaHeight);
            Bitmap boyukSek  = new Bitmap(Photo, boyukWidth, boyukHeight);

            //balacaSek.Save("~/Upload/Sekiller/balaca/" + newName);
            //ortaSek.Save("~/Upload/Sekiller/orta/" + newName);
            //boyukSek.Save("~/Upload/Sekiller/boyuk/" + newName);

            tbl_users Istfd   = (tbl_users)Session["Istifadeci"];
            tbl_sekil dbSekil = new tbl_sekil();

            dbSekil.Balacasekil = "/Upload/Sekiller/balaca/" + newName;
            dbSekil.Ortasekil   = "/Upload/Sekiller/orta/" + newName;
            dbSekil.Boyuksekil  = "/Upload/Sekiller/boyuk/" + newName;

            //dbSekil.ElaveEdenId = Istfd.MuellifId;

            db.tbl_sekil.Add(dbSekil);
            db.SaveChanges();
            return(dbSekil.SekilId);

            throw new NotImplementedException();
        }
예제 #7
0
        public virtual bool SetUserInfo(tbl_users tblUserInfo)
        {
            //  UpsertTableData<tbl_users>(tblUserInfo);

            UpdateTableData <tbl_users>(tblUserInfo);

            return(true);
        }
예제 #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_users tbl_users = db.tbl_users.Find(id);

            db.tbl_users.Remove(tbl_users);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #9
0
        public virtual tbl_users GetUserInfoByNickName(string userNickName)
        {
            sqlQuery = string.Format("WHERE UserNickName = N'{0}' AND isDeleted = '0'", userNickName);

            tbl_users value = GetTableData <tbl_users>(sqlQuery);

            return(value);
        }
예제 #10
0
        public virtual tbl_users GetUserInfo(string userNickName, string pswd)
        {
            sqlQuery = string.Format("WHERE nickname = N'{0}' AND password = '******' AND isDeleted = '0' ", userNickName, pswd);

            tbl_users value = GetTableData <tbl_users>(sqlQuery);

            return(value);
        }
예제 #11
0
 public ActionResult Edit(tbl_users tbl_users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_users));
 }
예제 #12
0
        public ActionResult TesdiqEle(tbl_users istfd, int id)
        {
            tbl_users usr = db.tbl_users.FirstOrDefault(x => x.UserId == id);

            usr.QebulEdildi  = true;
            TempData["Info"] = "İstifadəçi uğurlu şəkildə müəllif oldu";
            db.SaveChanges();

            return(RedirectToAction("YazarAktivlesdir"));
        }
예제 #13
0
 public ActionResult Edit([Bind(Include = "Id,first_name,last_name,email,contact_num,account_type,address, password")] tbl_users tbl_users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_users));
 }
예제 #14
0
 public ActionResult Edit([Bind(Include = "Id,anbarId,sematId,admin,anbardar,username,password,name,family,father,codemeli,pic,active")] tbl_users tbl_users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_users));
 }
예제 #15
0
        public ActionResult Create(tbl_users tbl_users)
        {
            if (ModelState.IsValid)
            {
                db.users.Add(tbl_users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_users));
        }
 public ActionResult Edit([Bind(Include = "U_Id,username,password,Role_id")] tbl_users tbl_users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Role_id = new SelectList(db.roles, "Role_Id", "role_name", tbl_users.Role_id);
     return(View(tbl_users));
 }
예제 #17
0
        public ActionResult Create([Bind(Include = "Id,first_name,last_name,email,contact_num,account_type,address, password")] tbl_users tbl_users)
        {
            if (ModelState.IsValid)
            {
                db.tbl_users.Add(tbl_users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_users));
        }
 public ActionResult Edit([Bind(Include = "MuellifId,Adi,Soyadi,Mail,Tarixi,Nick,SekilId,Aktiv,Muellifmi,Haqqinda")] tbl_users tbl_users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SekilId = new SelectList(db.tbl_sekil, "SekilId", "Balacasekil", tbl_users.SekilId);
     return(View(tbl_users));
 }
예제 #19
0
 public string EditUser(tbl_users userDetail)
 {
     try
     {
         userContext.UpdateUser(userDetail);
         return("User Updated");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #20
0
 public string CreateUser(tbl_users userDetail)
 {
     try
     {
         userContext.AddUser(userDetail);
         return("User Added");
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        // POST: api/Users

        public IHttpActionResult PostUser(tbl_users newUserDetails)
        {
            try
            {
                users.CreateUser(newUserDetails);
                return(Ok("User Added"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        string ValidateUser(string ua, string pwd)
        {
            tbl_users user = db.tbl_users.FirstOrDefault(x => x.Login == ua && x.Sifre == pwd);

            if (user != null)
            {
                return(user.Ad);
            }
            else
            {
                return("");
            }
        }
예제 #23
0
 public HttpResponseMessage Post(tbl_users user)
 {
     try
     {
         entities.tbl_users.Add(user);
         entities.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.Accepted, user));
     }
     catch (Exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Username already exists in database"));
     }
 }
예제 #24
0
        // GET: users/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_users tbl_users = db.tbl_users.Find(id);

            if (tbl_users == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_users));
        }
예제 #25
0
        public virtual bool CheckUserInfo(string nickName)
        {
            sqlQuery = string.Format("WHERE nickname = N'{0}' AND isDeleted = '0'", nickName);
            tbl_users value = GetTableData <tbl_users>(sqlQuery);

            if (value != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #26
0
        public HttpResponseMessage logincheck(tbl_users user)
        {
            //result = entities.sp_logincheck(user.username).FirstOrDefault();
            var result = entities.sp_login(user.username);

            if (result == null || result.ToString().Length == 0)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Username or password"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
        }
예제 #27
0
        public HttpResponseMessage savePassword(tbl_users n)
        {
            tbl_users s = entities.tbl_users.Where(t => t.username == n.username).FirstOrDefault();

            if (s == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Data cannot be found"));
            }
            else
            {
                s.password = n.password;
                entities.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, "1"));
            }
        }
        public ActionResult Login(tbl_users u)
        {
            var count = db.users.Where(x => x.username == u.username && x.password == u.password).Count();

            if (count == 0)
            {
                ViewBag.msg = "Invalid user";
                return(View());
            }
            else
            {
                FormsAuthentication.SetAuthCookie(u.username, false);
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create([Bind(Include = "MuellifId,Adi,Soyadi,Mail,Tarixi,Nick,SekilId,Aktiv,Muellifmi,Haqqinda")] tbl_users tbl_users, HttpPostedFileBase Sekil)
        {
            if (ModelState.IsValid)
            {
                tbl_users.SekilId   = SekilYukle(Sekil);
                tbl_users.MuellifId = Guid.NewGuid();
                tbl_users.Tarixi    = DateTime.Now;
                db.tbl_users.Add(tbl_users);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SekilId = new SelectList(db.tbl_sekil, "SekilId", "Balacasekil", tbl_users.SekilId);
            return(View(tbl_users));
        }
        // GET: AdminPanel/tbl_users/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_users tbl_users = db.tbl_users.Find(id);

            if (tbl_users == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SekilId = new SelectList(db.tbl_sekil, "SekilId", "Balacasekil", tbl_users.SekilId);
            return(View(tbl_users));
        }
 public void AddTotbl_users(tbl_users tbl_users)
 {
     base.AddObject("tbl_users", tbl_users);
 }
 public static tbl_users Createtbl_users(int userid)
 {
     tbl_users tbl_users = new tbl_users();
     tbl_users.userid = userid;
     return tbl_users;
 }
예제 #33
0
        public dtoResult Insert(dtoUserAccount t)
        {
            string hash = "";

            using (MD5 md5Hash = MD5.Create())
            {
                 hash= GetMd5Hash(md5Hash, t.passWord);
            }

            var result = new dtoResult();
            try
            {
                var obj = new tbl_users
                {
                    userName = t.userName,
                    passWord = hash,
                    firstName = t.firstName,
                    lastName = t.lastName,
                    middleName = t.middleName,
                    branchId = t.branchId,
                    emailAddress =  t.emailAddress,
                    status = 1,

                    dateCreated = DateTime.Now

                };

                DBContext.tbl_users.Add(obj);

                DBContext.SaveChanges();

                t.userName = obj.userName;
                result.isSuccessful = true;
                result.returnObj = t;
            }
            catch (Exception ex)
            {
                result.isSuccessful = false;
                result.errorMsg = ex.ToString();
            }

            return result;
        }