示例#1
0
        public JsonResult Save(Guid alias, string content)
        {
            using (NotepadEntities entities = new NotepadEntities())
            {
                var q = from n in entities.Notepads
                        where n.NotepadID == alias
                        select n;

                var notepad = q.SingleOrDefault();

                if (notepad != null)
                {
                    notepad.Content = content;
                    entities.SaveChanges();
                }
            }

            return(Json(new { Content = content, Result = "Success" }));
        }
示例#2
0
        public static string GetPlaceHolder()
        {
            string retVal = string.Empty;

            using (NotepadEntities entities = new NotepadEntities())
            {
                var q = from n in entities.Notepads
                        where n.Alias == "DefaultContent"
                        select n;

                var defaultNote = q.SingleOrDefault();

                if (defaultNote != null)
                {
                    retVal = defaultNote.Content;
                }
            }

            return(retVal);
        }
示例#3
0
        public JsonResult SaveWithConfig(Notepad notepad)
        {
            using (NotepadEntities entities = new NotepadEntities())
            {
                var noteToUpdate = entities.Notepads.Find(notepad.NotepadID);

                noteToUpdate.Content      = notepad.Content;
                noteToUpdate.LockPassword = notepad.LockPassword;
                noteToUpdate.Mime         = notepad.Mime;
                noteToUpdate.Mode         = notepad.Mode;
                noteToUpdate.ModifiedOn   = DateTime.Now;
                noteToUpdate.ShowContent  = notepad.ShowContent;
                noteToUpdate.Theme        = notepad.Theme;
                noteToUpdate.Title        = notepad.Title;

                entities.SaveChanges();

                return(Json(new
                {
                    Result = "Sucess"
                }));
            }
        }
示例#4
0
        public ActionResult Index(string id)
        {
            using (NotepadEntities entities = new NotepadEntities())
            {
                string tempAlias = (string.IsNullOrEmpty(id))
                        ? Guid.NewGuid().ToString("N").Substring(0, 8)
                        : id;

                var q = from n in entities.Notepads
                        where n.Alias == tempAlias
                        select n;

                var notepad = q.SingleOrDefault();

                if (notepad == null)
                {
                    Notepad newNote = new Notepad
                    {
                        Alias = tempAlias,
                    };

                    entities.Notepads.Add(newNote);

                    entities.SaveChanges();

                    Response.Redirect(tempAlias);

                    return(View());
                }

                ViewBag.Title = notepad.Title;

                //notepad.Content = GetDefaultNotepadContent(notepad.Content);

                return(View(notepad));
            }
        }