Beispiel #1
0
        public async Task <IActionResult> Index(string name, string myimg)
        {
            var stu = await studentBll.GetEntities(u => u.name == name).FirstOrDefaultAsync();

            if (myimg == null)
            {
                return(Content("<script>alert('图片未提交!');window.location.href='../Home/Index';</script>", "text/html", System.Text.Encoding.UTF8));
            }
            if (stu != null)
            {
                string diffImg = "安心睡吧!";
                stu.sub  = 1;
                stu.time = DateTime.Now.ToString();
                Common.SaveImage.ByStringToSave(name, myimg);
                if (System.IO.File.Exists("./wwwroot/StudentImage/陈淳.jpg"))
                {
                    if (Common.SaveImage.Compare("./wwwroot/StudentImage/" + name + ".jpg", "./wwwroot/StudentImage/陈淳.jpg") > 20)
                    {
                        diffImg = "但是与标准图片相差过大,请检查你的图片";
                    }
                }
                studentBll.Update(stu);
                return(Content("<script>alert('提交成功!" + diffImg + "');window.location.href='../Home/Index';</script>", "text/html", System.Text.Encoding.UTF8));
            }
            else
            {
                return(Content("<script>alert('你确定是本班的?');window.location.href='../Home/Index';</script>", "text/html", System.Text.Encoding.UTF8));
            }
        }
        public async Task <IActionResult> Index()//展示全部数据
        {
            var students = studentBll.GetEntities(n => n.id > 0).ToListAsync();

            return(View(await students));
        }