Пример #1
0
        public DataTable EditMyNotes([FromBody] MyNotes json)
        {
            DataTable dt = null;

            try
            {
                if (json.userid > 0 && json.id > 0)
                {
                    EPData ep = new EPData();
                    ep.EditMyNoteByCP(json);
                    dt = GetTable("true", "");
                    //SqlParameter[] sqlparam =null;
                    //sqlparam.(new SqlParameter() { });


                    //ep.EditMyNoteByCP("cp_EditMyNotes", sqlparam);
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的笔记(EditMyNotes)");
            }
            return(dt);
        }
Пример #2
0
        public DataTable CheckMyNotes([FromBody] MyNotes json)
        {
            DataTable dt = null;

            try
            {
                if (json.userid > 0 && json.id > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("SELECT * FROM EP_MyNotes WHERE UserId={0} AND ID ={1}", json.userid, json.id);
                    EPData ep = new EPData();
                    dt = ep.GetData(sb.ToString());
                }
                else
                {
                    dt = GetTable("false", "参数错误");
                }
            }
            catch (Exception ex)
            {
                dt = GetTable("false", ex.Message);
                Log.WriteError(ex, "我的笔记(CheckMyNotes)");
            }
            return(dt);
        }
Пример #3
0
        public void ShowWithoutNotes()
        {
            Lines lines    = new MyNotes(new EmptyDataBaseMock(), new [] { "show" }).execute();
            Lines expected = new Lines();

            Assert.AreEqual(expected, lines);
        }
Пример #4
0
        public void DeleteOneOk()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "delete", "0" }).execute();
            Lines expected = new Lines();

            expected.add("The note was deleted.", ConsoleColor.Green);
            Assert.AreEqual(expected, lines);
        }
Пример #5
0
        public void ShowOneNote()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "show", "2" }).execute();
            Lines expected = new Lines();

            expected.add("2: 22-22-2222 - ccc [TAG1 TAG2]");
            Assert.AreEqual(expected, lines);
        }
Пример #6
0
        public void NewNoteCreatedOkTest()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "new", "ok" }).execute();
            Lines expected = new Lines();

            expected.add("Your note was saved.", ConsoleColor.Green);
            Assert.AreEqual(expected, lines);
        }
Пример #7
0
        public void DeleteAllCorrect()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "delete", "all" }).execute();
            Lines expected = new Lines();

            expected.add("All notes were deleted.", ConsoleColor.Green);
            Assert.AreEqual(expected, lines);
        }
Пример #8
0
        public void DeleteOneWithGenericError()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "delete", "2" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error while deleting the note.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #9
0
        public void editWithLargeIndex()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "99", "index" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error updating the note: Index is too large.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #10
0
        public void DeleteAllIncorrect()
        {
            Lines lines    = new MyNotes(new EmptyDataBaseMock(), new [] { "delete", "all" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error while deleting the notes.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #11
0
        public void editKo()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "0", "ko" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error updating the note.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #12
0
        public void UntagNonExistingTagFails()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "untag", "0", "contains" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error updating the note: The note does not contain that tag.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #13
0
        public void DeleteOneWithIncorrectIndex()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "delete", "1" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error while deleting the note: Index is too large.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #14
0
        public void XtagWithIncorrectIndexFails()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "xtag", "0", "A", "index" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error updating the note: Index is too large.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #15
0
        public void ShowOneNoteWithWrongIndex()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "show", "99" }).execute();
            Lines expected = new Lines();

            expected.add("Wrong index '99' specified.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #16
0
        public void XtagTagAlreadyExistingTagFails()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "xtag", "0", "A", "tag" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error updating the note: The note already contains that tag.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #17
0
        public void NewNoteFailTest()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "new", "ko" }).execute();
            Lines expected = new Lines();

            expected.add("There was an error saving the note.", ConsoleColor.Red);
            Assert.AreEqual(expected, lines);
        }
Пример #18
0
        public void XtagCorrect()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "xtag", "0", "A", "ok" }).execute();
            Lines expected = new Lines();

            expected.add("The tag was changed.", ConsoleColor.Green);
            Assert.AreEqual(expected, lines);
        }
Пример #19
0
        public void editOk()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "0", "ok" }).execute();
            Lines expected = new Lines();

            expected.add("Your note was updated.", ConsoleColor.Green);
            Assert.AreEqual(expected, lines);
        }
Пример #20
0
        public void editWithWrongParameterIndex()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "A", "index" }).execute();
            Lines expected = new Lines();

            expected.add("Wrong index specified.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #21
0
        public void CantCreateEmptyNote()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "new" }).execute();
            Lines expected = new Lines();

            expected.add("You can't create an empty note.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #22
0
        public void editWithIncorrectParameters()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "0" }).execute();
            Lines expected = new Lines();

            expected.add("You need to specify the index of the note to edit and the new text.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #23
0
        public void SearchWithMissingParameters()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "search" }).execute();
            Lines expected = new Lines();

            expected.add("You need to specify a search mode and a search criteria.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #24
0
        public void cantEditWithEmptyText()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "edit", "0", "" }).execute();
            Lines expected = new Lines();

            expected.add("You can't set an empty text.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #25
0
        public void SearchByDate()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "search", "date", "21-21-2121" }).execute();
            Lines expected = new Lines();

            expected.add("3: 21-21-2121 - bbb [TAG]");
            expected.add("8: 21-21-2121 - ccc [TAG1 TAG2]");
            Assert.AreEqual(expected, lines);
        }
Пример #26
0
        public void DeleteWithIncorrectParameters()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "delete" }).execute();
            Lines expected = new Lines();

            expected.add("You need to specify 'all' or an index", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #27
0
        public void SearchWithWrongModeFails()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "search", "blah", "blah" }).execute();
            Lines expected = new Lines();

            expected.add("Unknown search mode.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #28
0
        public void UntagFailsWithoutIndex()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "untag" }).execute();
            Lines expected = new Lines();

            expected.add("You need to specify the index of a note and the tag to remove.", ConsoleColor.Yellow);
            expected.add(incorrectParameterEnd());
            Assert.AreEqual(expected, lines);
        }
Пример #29
0
        public void ShowAllNotes()
        {
            Lines lines    = new MyNotes(new DataBaseMock(), new [] { "show" }).execute();
            Lines expected = new Lines();

            expected.add("0: 20-20-2020 - aaa");
            expected.add("1: 21-21-2121 - bbb [TAG]");
            expected.add("2: 22-22-2222 - ccc [TAG1 TAG2]");
            Assert.AreEqual(expected, lines);
        }
Пример #30
0
        /// <summary>
        /// get user notes
        /// </summary>
        IResult MyNotes_Get()
        {
            IResult result = new Result();
            dynamic view   = new MyNotes();

            // view.Notes = AppData.GetBaseUrl() + "note/MyNotes_Ajax/";
            view.Notes = WebNoteBiz.GetUserNotes(WebShell.Utilities.User.Id);
            HttpContext.Current.Session["activeMI"] = "my_notes";
            string AjaxUrlEdit   = AppData.GetBaseUrl() + "note/edit";
            string AjaxUrlDelete = AppData.GetBaseUrl() + "note/delete";

            view.SetValue("AjaxUrlEdit", AjaxUrlEdit);
            view.SetValue("AjaxUrlDelete", AjaxUrlDelete);
            result = presenter.GetViewHTML("mynotes.htm", view);
            return(result);
        }
 public override System.Web.Mvc.ActionResult SaveUser(MyNotes.UI.Web.ViewModels.User.UserViewModel userViewModel) {
     var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.SaveUser);
     callInfo.RouteValueDictionary.Add("userViewModel", userViewModel);
     return callInfo;
 }
Пример #32
0
 public override System.Web.Mvc.ActionResult ValidateCredentials(MyNotes.UI.Web.ViewModels.Admin.User.UserCredentialViewModel viewmodel) {
     var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.ValidateCredentials);
     callInfo.RouteValueDictionary.Add("viewmodel", viewmodel);
     return callInfo;
 }
 public override System.Web.Mvc.ActionResult SaveGroup(MyNotes.UI.Web.ViewModels.Admin.GroupViewModel groupViewModel) {
     var callInfo = new T4MVC_ActionResult(Area, Name, ActionNames.SaveGroup);
     callInfo.RouteValueDictionary.Add("groupViewModel", groupViewModel);
     return callInfo;
 }