示例#1
0
        private string ChangeNoteName(string[] args)
        {
            if (!ArgsHelper.CheckArgs(args, 4, 2))
            {
                return("ae");
            }
            int id = int.Parse(args[2]);

            if (!ArgsHelper.CheckLoginPassword(args[0], args[1]) || !ArgsHelper.NoteIsExist(id))
            {
                return("False");
            }

            if (ArgsHelper.IsAne(args[0], args[1], id))
            {
                return("ane");
            }


            Note current = DBContext.Notes.Where(x => x.Id == id).First();

            current.Name        = args[3];
            current.LastChanged = DateTime.Now;

            return("True");
        }
示例#2
0
        private string DuplicateNote(string[] args)
        {
            if (!ArgsHelper.CheckArgs(args, 6, 2, 3, 4, 5))
            {
                return("ae");
            }
            if (!ArgsHelper.CheckLoginPassword(args[0], args[1]))
            {
                return("False");
            }
            int id = int.Parse(args[2]);

            if (!ArgsHelper.NoteIsExist(id))
            {
                return("ae");
            }
            if (ArgsHelper.IsAne(args[0], args[1], id))
            {
                return("ane");
            }

            int      day   = int.Parse(args[3]);
            int      month = int.Parse(args[4]);
            int      year  = int.Parse(args[5]);
            DateTime newCreated;

            try { newCreated = new DateTime(int.Parse(args[5]), int.Parse(args[4]), int.Parse(args[3])); }
            catch { return("ae"); }

            Note note  = DBContext.Notes.Where(x => x.Id == id).First();
            Note dNote = new Note(note.User, DBContext.Collections.Where(x => x.Id == 1).First(), note.Name, note.Text, new DateTime(year, month, day), DateTime.Now);

            DBContext.Notes.Add(dNote);
            return(dNote.Id.ToString());
        }
示例#3
0
        private string InsertTextToNote(string[] args)
        {
            if (!ArgsHelper.CheckArgs(args, 5, 2, 3))
            {
                return("ae");
            }
            int id    = int.Parse(args[2]);
            int count = int.Parse(args[3]);

            if (!ArgsHelper.CheckLoginPassword(args[0], args[1]))
            {
                return("False");
            }

            if (ArgsHelper.IsAne(args[0], args[1], id))
            {
                return("ane");
            }

            if (!ArgsHelper.NoteIsExist(id))
            {
                return("False");
            }

            Note note = DBContext.Notes
                        .Where(x => x.Id == id).First();

            if (note.Text.Length < count)
            {
                return("ae");
            }
            note.Text        = note.Text.Substring(0, note.Text.Length - count) + args[4];
            note.LastChanged = DateTime.Now;
            return("True");
        }
示例#4
0
        private string DuplicateParagraphMission(string[] args)
        {
            if (!ArgsHelper.CheckArgs(args, 6, 2, 3, 4, 5))
            {
                return("ae");
            }
            if (!ArgsHelper.CheckLoginPassword(args[0], args[1]))
            {
                return("False");
            }
            int     id      = int.Parse(args[2]);
            Mission mission = DBContext.Missions.Where(x => x.Id == id).First();

            if (!ArgsHelper.NoteIsExist(mission.Action.NoteId))
            {
                return("ae");
            }
            if (ArgsHelper.IsAne(args[0], args[1], mission.Action.NoteId))
            {
                return("ane");
            }

            int      day   = int.Parse(args[3]);
            int      month = int.Parse(args[4]);
            int      year  = int.Parse(args[5]);
            DateTime newCreated;

            try { newCreated = new DateTime(int.Parse(args[5]), int.Parse(args[4]), int.Parse(args[3])); }
            catch { return("ae"); }

            Note note = new Note(DBContext.Users.Where(x => x.Login == args[0] && x.Password == args[1]).First(),
                                 DBContext.Collections.Where(x => x.Id == 1).First(),
                                 mission.Action.Note.Name,
                                 mission.Action.Note.Text,
                                 newCreated,
                                 DateTime.Now);

            DBContext.Notes.Add(note);
            Database.Context.Action action = new Database.Context.Action(note, DateTime.MinValue, DateTime.MaxValue);
            DBContext.Actions.Add(action);
            Collection collection = new Collection();

            collection.Count = ((Collection)mission.Context).Count;
            DBContext.Collections.Add(collection);
            Mission dMission = new Mission(action, false, collection);

            DBContext.Missions.Add(dMission);
            List <Point> points = DBContext.Points.Where(x => x.ParagraphId == mission.ContextId).ToList();
            string       result = note.Id.ToString() + "|" + action.Id.ToString() + "|" + dMission.Id.ToString() + "|" + collection.Id.ToString();

            foreach (Point point in points)
            {
                Point dPoint = new Point(dMission.ContextId, point.Name, point.IsChecked);
                DBContext.Points.Add(dPoint);
                result += "|" + dPoint.Id.ToString();
            }
            return(result);
        }