Пример #1
0
 public void setconnectid(string name)
 {
     data = _service.LoginData.SingleOrDefault(c => c.name == name);
     data.ConnectionID = Context.ConnectionId;
     _service.LoginData.Attach(data);
     _service.Entry(data).State = EntityState.Modified;
     _service.SaveChanges();
 }
Пример #2
0
        public ActionResult Create([Bind(Include = "ID,user_id,user_name,pwd,user_email,user_type,phone_number,online_state,contact_list,room_list")] ChatUser chatUser)
        {
            if (ModelState.IsValid)
            {
                db.ChatUsers.Add(chatUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(chatUser));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "ID,room_id,room_name,owner_id,member_list,make_date")] Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(room));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,message_id,room_id,sender_id,receiver_id,sender_date,receiver_date,context")] Message message)
        {
            if (ModelState.IsValid)
            {
                db.Messages.Add(message);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(message));
        }
Пример #5
0
        public ActionResult UyeEkle(Users tabloUser)
        {
            DB.User.Add(new Users
            {
                UserName = tabloUser.UserName,
                Email    = tabloUser.Email
            });
            int sonuc = DB.SaveChanges();

            if (sonuc > 0)
            {
                return(RedirectToAction("UyeleriListele", "AdminPaneli"));
            }
            return(View());
        }
Пример #6
0
        public ActionResult Index(string KullaniciAdi, string KullaniciEmail)
        {
            Users user = DB.User.Where(k => k.UserName == KullaniciAdi || k.Email == KullaniciEmail).FirstOrDefault();

            if (user == null)
            {
                DB.User.Add(new Users
                {
                    UserName = KullaniciAdi,
                    Email    = KullaniciEmail,
                });
                int sonuc = DB.SaveChanges();
                if (sonuc == 1)
                {
                    Session["isim"] = KullaniciAdi;
                    return(RedirectToAction("Chat", "Home"));
                }
            }
            else
            {
                Session["isim"] = KullaniciAdi;
                return(RedirectToAction("Chat", "Home"));
                //ViewBag.Loginmesaj = "Kayıtlı kullanıcı!!";
            }

            ViewBag.Loginmesaj = "Kullanıcı Adı veya e-maili hatalı!!";
            return(View());
        }
Пример #7
0
        public override Task OnConnected()
        {
            var user_id = Context.QueryString["user_id"];

            var result = Users.SingleOrDefault(u => u.User_ID == user_id && u.ConnectionID == Context.ConnectionId);

            if (result == null)
            {
                User user = new User()
                {
                    User_ID = user_id, ConnectionID = Context.ConnectionId
                };
                Users.Add(user);
                var r = db.ChatUsers.SingleOrDefault(c => c.user_id == user_id);
                r.online_state = true;
                Clients.Group("PUBLIC_ROOM").GetMessage(user_id, "LOG_IN", "PUBLIC_ROOM", "");
                db.SaveChanges();
            }

            //Clients.Others.userConnected(user.User_ID);
            return(base.OnConnected());
        }
Пример #8
0
 public void Register(string userName, string pswd)
 {
     try
     {
         User newUser = new User
         {
             Login    = userName,
             Password = pswd
         };
         dbcontext.Users.Add(newUser);
         dbcontext.SaveChanges();
         Connect(userName, pswd);
     }
     catch
     {
     }
 }
Пример #9
0
        public void Send(string name, string message)
        {
            int userId = 0;

            userId = DB.User.Where(k => k.UserName == name).FirstOrDefault().UserId;
            DB.Mesaj.Add(new Models.Mdl.Mesajlar
            {
                Mesaj      = message,
                UserId     = userId,
                MesajTarih = DateTime.Now.Date.ToShortDateString(),
                MesajSaat  = DateTime.Now.TimeOfDay,
            });

            DB.SaveChanges();

            // Call the addNewMessageToPage method to update clients.
            Clients.All.addNewMessageToPage(name, message);
        }
Пример #10
0
 public int CommitChanges()
 {
     return(_context.SaveChanges());
 }
Пример #11
0
 public void CommitChanges()
 {
     context.SaveChanges();
 }
Пример #12
0
        public Object login(JObject person)
        {
            string user_id;
            string email;
            string pwd;
            string auth_token;
            long   utc_time;
            string device_id = "";

            Response_Person rp = new Response_Person();

            try
            {
                user_id   = person["user_id"].ToString();
                device_id = person["device_id"].ToString();
                if (!String.IsNullOrEmpty(device_id))
                {
                    if (String.IsNullOrEmpty(user_id))
                    {
                        var result_chatuser = db.ChatUsers.SingleOrDefault(d => d.device_id == device_id);
                        if (result_chatuser != null)
                        {
                            rp.res_type   = "login";
                            rp.state      = 9;
                            rp.user_id    = result_chatuser.user_id;
                            rp.user_name  = result_chatuser.user_name;
                            rp.auth_token = result_chatuser.auth_token;
                            return(rp);
                        }
                    }
                }


                email = person["user_email"].ToString();
                if (user_id.Contains("@"))
                {
                    email   = user_id;
                    user_id = "";
                }

                pwd = person["pwd"].ToString();

                //string offset_time_str = person["offset_time"].ToString();
                //offset_time = Convert.ToInt64(offset_time_str);
                utc_time = DateTime.UtcNow.Ticks;
            }
            catch (Exception e)
            {
                string estring = e.ToString();
                //rp.res_type = "login";
                rp.res_type   = estring;
                rp.state      = 5;
                rp.user_id    = "";
                rp.user_name  = "";
                rp.auth_token = "";
                return(rp);
            }



            var chatusers = from m in db.ChatUsers select m;

            if (!String.IsNullOrEmpty(user_id))
            {
                chatusers = chatusers.Where(s => s.user_id == user_id);
                if (!chatusers.Any())
                {
                    rp.res_type   = "login";
                    rp.state      = 2;
                    rp.user_id    = "";
                    rp.user_name  = "";
                    rp.auth_token = "";
                    return(rp);
                }
            }
            if (!String.IsNullOrEmpty(email))
            {
                chatusers = chatusers.Where(s => s.user_email == email);
                if (!chatusers.Any())
                {
                    rp.res_type   = "login";
                    rp.state      = 2;
                    rp.user_id    = "";
                    rp.user_name  = "";
                    rp.auth_token = "";
                    return(rp);
                }
            }
            if (!String.IsNullOrEmpty(pwd))
            {
                chatusers = chatusers.Where(s => s.pwd == pwd);
                if (!chatusers.Any())
                {
                    rp.res_type   = "login";
                    rp.state      = 3;
                    rp.user_id    = "";
                    rp.user_name  = "";
                    rp.auth_token = "";
                    return(rp);
                }
            }

            auth_token = Guid.NewGuid().ToString();

            var result = db.ChatUsers.SingleOrDefault(b => b.user_id == user_id);

            if (string.IsNullOrEmpty(user_id))
            {
                result = db.ChatUsers.SingleOrDefault(b => b.user_email == email);
            }

            try
            {
                result.auth_token   = auth_token;
                result.online_state = true;
                result.last_logdate = utc_time;
                result.device_id    = device_id;
                db.SaveChanges();
                if (!string.IsNullOrEmpty(device_id))
                {
                    var dev_result = db.ChatUsers.Where(k => k.device_id == device_id && k.user_id != user_id);
                    foreach (ChatUser cu in dev_result)
                    {
                        cu.device_id = "";
                    }
                    db.SaveChanges();
                }
            }catch (Exception e1)
            {
                rp.res_type   = "login";
                rp.state      = 4;
                rp.user_id    = "";
                rp.user_name  = "";
                rp.auth_token = "";
                return(rp);
            }



            rp.res_type   = "login";
            rp.state      = 0;
            rp.auth_token = auth_token;
            rp.user_id    = result.user_id;
            rp.user_name  = result.user_name;
            return(rp);
        }