コード例 #1
0
        public JsonResult Check(string auser, string apass)
        {
            channelEntities ch = new channelEntities();
            classchannel    cs = new classchannel();



            try
            {
                cs.users = (from iduse in ch.users.AsEnumerable()
                            where iduse.username == auser && iduse.password == apass
                            select new
                {
                    auser1 = iduse.room.ToString()
                }).First();
                if (cs.users != null)
                {
                    return(Json(new { status = "200", message = "suc" }));
                }
                else
                {
                    return(Json(new { status = "500", message = "faill" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { status = "500", message = e.Message, data = "error" }));
            }
        }
コード例 #2
0
        public JsonResult Test(string roomat)
        {
            channelEntities ch = new channelEntities();
            classchannel    cs = new classchannel();

            try
            {
                cs.users = (from iduse in ch.users.AsEnumerable()
                            where iduse.room == roomat
                            select new
                {
                    rooma = iduse.username
                }).First();
                if (cs.users != null)
                {
                    return(Json(new { status = "200", message = "suc", data = cs.users }));
                }
                else
                {
                    return(Json(new { status = "500", message = "ไม่มีนะครับ" }));
                }
            }
            catch (Exception e)
            {
                return(Json(new { status = "500", message = e.Message, data = "ไม่มีนะจ้ะ" }));
            }
        }
コード例 #3
0
        public JsonResult ActionCreate(string ffName)
        {
            try
            {
                dynamic         item = JsonConvert.DeserializeObject(ffName);
                channelEntities tfn  = new channelEntities();
                user            p1   = new user();
                p1.username = item.user;
                p1.password = item.pass;
                p1.room     = item.roo;
                tfn.users.Add(p1);
                tfn.SaveChanges();

                //pro1Entities1 tfn = new pro1Entities1();

                //fullname p1 = new fullname();
                //p1.firstName = item.fName;
                //p1.lastName = item.lName;
                //tfn.fullnames.Add(p1);
                //tfn.SaveChanges();

                return(Json(new { status = "200", message = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "500", message = ex.Message }));
            }
        }
コード例 #4
0
ファイル: PhotoController.cs プロジェクト: Crulos/P4
        public ActionResult Photo()
        {
            channelEntities dbPhoto = new channelEntities();
            classPro1       Photo   = new classPro1();


            Photo.rooms = (from users in dbPhoto.rooms.AsEnumerable()
                           select new
            {
                NamePhoto = users.NamePhoto
            }).ToList();
            return(View(Photo.rooms));
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: Crulos/P4
 public JsonResult Logout()
 {
     try
     {
         string          test  = Session["ID"].ToString();
         channelEntities p1    = new channelEntities();
         user            model = p1.users.FirstOrDefault(x => x.userName == test);
         model.status     = false;
         Session["login"] = false;
         p1.SaveChanges();
         return(Json(new { status = "200", message = "success" }));
     } catch (Exception ex)
     { return(Json(new { status = "500", message = ex.Message })); }
 }
コード例 #6
0
        public ActionResult Index()
        {
            channelEntities ch = new channelEntities();
            classchannel    cs = new classchannel();

            cs.users = (
                from full in ch.users.AsEnumerable()
                select new
            {
                id1 = full.id,
                username1 = full.username,
                password1 = full.password
            }).ToList();

            return(View(cs));
        }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: Crulos/P4
 public JsonResult Master()
 {
     try
     {
         channelEntities p1      = new channelEntities();
         classPro1       modelP1 = new classPro1();
         modelP1.rooms = (
             from full in p1.rooms.AsEnumerable()
             select new
         {
             cName1 = full.cName,
         }).ToList();
         return(Json(new { status = "200", message = "success", data = modelP1.rooms }));
     }
     catch (Exception ex)
     { return(Json(new { status = "500", message = ex.Message, data = "" })); }
 }
コード例 #8
0
ファイル: HomeController.cs プロジェクト: Crulos/P4
        public ActionResult Login2(string ffName)
        {
            try
            {
                dynamic item  = JsonConvert.DeserializeObject(ffName);
                int     fName = int.Parse(item.fName.ToString());
                string  lName = item.lName;

                channelEntities p1      = new channelEntities();
                classPro1       modelP1 = new classPro1();
                modelP1.rooms = (
                    from full in p1.rooms.AsEnumerable()
                    where full.cID == fName && full.cPass == lName
                    select new
                {
                    cName1 = full.cName,
                    //NamePhoto1 = full.NamePhoto
                }).First();



                if (modelP1.rooms != null)
                {
                    //Session["ID"] = fName;
                    //Session["PASS"] = lName;
                    //user model = p1.users.FirstOrDefault(x => x.userName == fName && x.userPass == lName);
                    //model.status = true;
                    //Session["login"] = true;
                    //p1.SaveChanges();

                    return(Json(new { status = "200", message = "success" }));
                }
                else
                {
                    //Session["login"] = false;
                    return(Json(new { status = "500", message = "cannot login" }));
                }
            }
            catch (Exception ex)
            {
                Session["login"] = false;
                return(Json(new { status = "500", message = ex.Message }));
            }
        }
コード例 #9
0
ファイル: HomeController.cs プロジェクト: Crulos/P4
        public JsonResult ActionCreate(string ffName)
        {
            try
            {
                dynamic item = JsonConvert.DeserializeObject(ffName);

                channelEntities tfn = new channelEntities();

                user p1 = new user();
                p1.userName = item.fName;
                p1.userPass = item.lName;
                tfn.users.Add(p1);
                tfn.SaveChanges();

                return(Json(new { status = "200", message = "success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "500", message = ex.Message }));
            }
        }
コード例 #10
0
ファイル: PhotoController.cs プロジェクト: Crulos/P4
        public ActionResult ShowAlbum()
        {
            channelEntities dbPhoto = new channelEntities();

            return(View(dbPhoto.rooms.ToList()));
        }
コード例 #11
0
ファイル: PhotoController.cs プロジェクト: Crulos/P4
        public JsonResult ImageUpload(string Account)
        {
            try
            {
                channelEntities pro1Entities = new channelEntities();
                dynamic         data         = JsonConvert.DeserializeObject(Account);
                room            albums       = new room();
                albums.NamePhoto = data.Album;
                albums.cName     = data.id.ToString();
                albums.cPass     = data.pass.ToString();
                //albums.CreateAt = DateTime.Now;
                pro1Entities.rooms.Add(albums);
                pro1Entities.SaveChanges();
                Directory.CreateDirectory(Server.MapPath("~/Photos/" + albums.cID));


                int i = 1;
                foreach (dynamic items in data.img)
                {
                    // Convert Base64 String to byte[]
                    string[]     words      = (items.fileName).ToString().Split(',');
                    byte[]       imageBytes = Convert.FromBase64String(words[1]);
                    MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);

                    // Convert byte[] to Image
                    ms.Write(imageBytes, 0, imageBytes.Length);
                    System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
                    string newFile             = i + ".jpg";
                    string filePath            = Path.Combine(Server.MapPath("~/Photos/" + albums.cID), newFile);
                    //string filePath = Path.Combine(Server.MapPath(@"~C:\Photos\" + albums.IDAlbum), newFile);
                    //string vPath = filePath.Replace(@"C:\code", "~").Replace(@"\", "/");
                    string dbPathImageMore = "/Photos/" + albums.cID.ToString() + "/" + newFile;



                    image.Save(filePath, ImageFormat.Jpeg);
                    //HttpContextBase
                    string currentUrl = System.Web.HttpContext.Current.Request.Url.ToString().ToLower();
                    if (currentUrl.Contains("localhost"))   //  เป็น  version ทำในเครื่องหรือป่าว
                    {
                        //trucur = "yes";   // ถ้าทำในเครื่อง
                    }
                    else
                    {
                        //nocur = "no";     // version deploy
                    }
                    //rooms photostock = new rooms();
                    //photostock.NamePhoto1 = dbPathImageMore;
                    //photostock.cID1 = albums.cID;
                    //pro1Entities.rooms.Add(photostock);
                    //user model = p1.users.FirstOrDefault(x => x.userName == fName && x.userPass == lName);
                    //model.status = true;
                    //Session["login"] = true;
                    //p1.SaveChanges();
                    i++;
                }
                pro1Entities.SaveChanges();
                return(Json(new { status = "200", message = "Success" }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = "500", message = ex.Message }));
            }
        }