Esempio n. 1
0
 public bool AddNote(tbl_Notes model)
 {
     try
     {
         model.CreateDate = DateTime.Now;
         db.tbl_Notes.Add(model);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 2
0
 public ActionResult Edit(tbl_Notes model)
 {
     if (!User.Identity.IsAuthenticated)
     {
         return(RedirectToAction("DangNhap", "Login"));
     }
     if (dao.EditNote(model))
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(model));
     }
 }
Esempio n. 3
0
        public bool EditNote(tbl_Notes model)
        {
            try
            {
                var res = GetNote(model.ID);
                if (res == null)
                {
                    return(false);
                }
                res.Name    = model.Name;
                res.Content = model.Content;
                res.Public  = model.Public;

                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 4
0
        public ActionResult Index(tbl_Notes model, string clientCaptcha)
        {
            string serverCaptcha = Session["CAPTCHA"].ToString();

            if (!clientCaptcha.Equals(serverCaptcha))
            {
                ViewBag.ShowCAPTCHA = serverCaptcha;

                ViewBag.CaptchaError = "Wrong captcha !!!";
                Session["CAPTCHA"]   = GetRandomText();
                return(View(model));
            }
            model.ID = Guid.NewGuid();
            //model.Content = model.Content.Replace(Environment.NewLine, "<br/>");
            if (dao.AddNote(model))
            {
                return(RedirectToAction("Index", new { id = model.ID }));
            }
            else
            {
                return(View());
            }
        }