Пример #1
0
        public ActionResult EditCategory(NoteCategory category)
        {
            var user = db.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault();

            ViewBag.Setting   = "active";
            ViewBag.MCategory = "active";

            var Cat = db.NoteCategories.Where(x => x.ID == category.ID).FirstOrDefault();

            var check = db.NoteCategories.Where(x => x.ID != category.ID && x.Name == category.Name).FirstOrDefault();

            if (check != null)
            {
                ModelState.AddModelError("Name", "This Category Name Already Exist");
                return(View(category));
            }

            if (ModelState.IsValid)
            {
                Cat.Name         = category.Name;
                Cat.Description  = category.Description;
                Cat.ModifiedDate = DateTime.Now;
                Cat.ModifiedBy   = user.ID;
                db.Configuration.ValidateOnSaveEnabled = false;
                db.SaveChanges();

                return(RedirectToAction("Index", "ManageCategory"));
            }
            else
            {
                ViewBag.Error = "Some Error Occure! Please Try Again";
                return(View(category));
            }
        }
Пример #2
0
        /// <summary>
        /// Сортирует список заметок по дате редактирования,
        /// оставляя заметки выбранный категории
        /// </summary>
        /// <param name="notes">Список заметок</param>
        /// <param name="category">Категория заметок</param>
        /// <returns>Отсортированный по дате редактирования
        /// Список заметок конкретной категории</returns>
        public List <Note> SortNotes(List <Note> notes, NoteCategory category)
        {
            var categoryNotes = notes.Where(note => note.Category == category).ToList();
            var sortedNotes   = categoryNotes.OrderByDescending(note => note.ModifiedDate).ToList();

            return(sortedNotes);
        }
Пример #3
0
        public ActionResult AddCategory(NoteCategory category)
        {
            var user = db.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault();

            ViewBag.Setting   = "active";
            ViewBag.MCategory = "active";

            var CheckCat = db.NoteCategories.Where(x => x.Name == category.Name).FirstOrDefault();

            if (CheckCat != null)
            {
                ModelState.AddModelError("Name", "This Category Name Already Exist");
                return(View(category));
            }

            if (ModelState.IsValid)
            {
                NoteCategory cat = new NoteCategory();
                cat.Name         = category.Name;
                cat.Description  = category.Description;
                cat.CreatedDate  = DateTime.Now;
                cat.ModifiedDate = DateTime.Now;
                cat.CreatedBy    = user.ID;
                cat.IsActive     = true;
                db.NoteCategories.Add(cat);
                db.SaveChanges();

                return(RedirectToAction("Index", "ManageCategory"));
            }
            else
            {
                ViewBag.Error = "Some Error Occure! Please Try Again";
                return(View(category));
            }
        }
Пример #4
0
        // Кнопки.
        #region Buttons

        private void OkButton_Click(object sender, EventArgs e)
        {
            if (TitleTextBox.Text == "" || NoteTextBox.Text == "")
            {
                //Ничего не делаем
                MessageBox.Show("Title and note content shouldn't be empty");
            }
            else
            {
                if (IsEdit)                 // условие, при котором уже созданая заметка редактируется
                {
                    DialogResult result = MessageBox.Show("Save changes to current note?", "NoteApp",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)                     // подтверждение сохранения изменений
                    {
                        CurrentCategory = (NoteCategory)CategoryComboBox.SelectedIndex;
                        var CurrentCreationDateTime = CurrentNote.DateOfCreation;
                        CurrentNote.DateOfCreation = CurrentCreationDateTime;
                        CurrentNote.Name           = TitleTextBox.Text;
                        CurrentNote.Content        = NoteTextBox.Text;
                        CurrentNote.Category       = CurrentCategory;
                    }
                }
                else
                {
                    CurrentCategory = (NoteCategory)CategoryComboBox.SelectedIndex;
                    CurrentNote     = new Note(TitleTextBox.Text, NoteTextBox.Text, CurrentCategory);
                }

                DialogResult = DialogResult.OK;
            }
        }
Пример #5
0
        /// <summary>
        /// инициализация лавная форма.
        /// </summary>
        public MainForm()
        {
            _project = ProjectManager.Deserializer(path);
            InitializeComponent();
            this.KeyPreview = true;
            foreach (var category in Enum.GetValues(typeof(NoteCategory)))
            {
                ComboBoxCategory.Items.Add(category);
            }
            ComboBoxCategory.Items.Add("All");
            foreach (var note in _project.ListNote.ToArray())
            {
                NoteListBox.Items.Add(note.Name);
            }
            foreach (int i in NoteCategory.GetValues(typeof(NoteCategory)))
            {
                lenghtEnum = i;
            }
            int j = _project.CurrentNote;

            ComboBoxCategory.SelectedIndex = lenghtEnum + 1;
            if (j >= 0)
            {
                NoteListBox.SelectedIndex = j;
                WriteInterface();
            }
        }
Пример #6
0
 public void DeleteCategory(NoteCategory category)
 {
     if (category == null || category.Id == 0)
     {
         return;
     }
     _categoryRepository.DeleteById(category.Id);
 }
Пример #7
0
        public void TestCategoryGet_CorrectValue(NoteCategory expected, string message)
        {
            _note.NoteCategory = expected;
            var actual = _note.NoteCategory;

            Assert.AreEqual(expected, actual, "Геттер категории заметки возвращает неправильную информацию");
            Assert.AreEqual(expected, _note.NoteCategory, "Сеттер категории заметки возвращает неправильную информацию");
        }
Пример #8
0
 /// <summary>
 /// Конструктор, который устанавливает значения полей заметки.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="content"></param>
 /// <param name="category"></param>
 public Note(string name, string content, NoteCategory category)
 {
     Name           = name;
     Content        = content;
     Category       = category;
     DateOfCreation = DateTime.Now;
     DateOfLastEdit = DateTime.Now;
 }
Пример #9
0
 private Note(string name, NoteCategory category, string text, DateTime created, DateTime modified)
 {
     _name     = name;
     _category = category;
     _text     = text;
     _created  = created;
     _modified = modified;
 }
Пример #10
0
        private void BtnAddCategory(object sender, RoutedEventArgs e)
        {
            NoteCategory nc = new NoteCategory();

            nc.category_parent = 1;
            nc.category_title  = "New Category";
            DB.Add(nc);
            UpdateNotes();
        }
Пример #11
0
        private void CreateNewCategoryClick(object sender, RoutedEventArgs e)
        {
            NoteCategory nc = new NoteCategory();

            nc.category_title  = "New Category";
            nc.category_parent = id;
            DB.Add(nc);
            UpdateNotes();
        }
        public ActionResult DeleteCategory(int id)
        {
            NoteCategory note = dbobj.NoteCategories.Find(id);

            note.isActive           = false;
            dbobj.Entry(note).State = EntityState.Modified;
            dbobj.SaveChanges();
            return(RedirectToAction("ManageCategory", "ManageSystem"));
        }
Пример #13
0
 public ActionResult DeleteCategory(int?ID)
 {
     if (ID != null)
     {
         NoteCategory countryData = db.NoteCategories.Where(x => x.ID == ID).FirstOrDefault();
         countryData.IsActive = false;
         db.SaveChanges();
     }
     return(RedirectToAction("ManageCategory", "Category"));
 }
Пример #14
0
 private void AddCategories(NoteCategory noteCategory)
 {
     foreach (NoteCategory nc in DB.GetNoteCategories())
     {
         if (nc.category_parent == noteCategory.category_id)
         {
             CreateNewCategory(nc);
             AddCategories(nc);
         }
     }
 }
Пример #15
0
        private void CreateNewCategory(NoteCategory noteCategory)
        {
            TextBox tb = new TextBox();

            tb.Name       = "cate" + noteCategory.category_id;
            tb.Text       = noteCategory.category_title;
            tb.Focusable  = true;
            tb.MaxLength  = 20;
            tb.AllowDrop  = true;
            tb.IsReadOnly = false;
            tb.Cursor     = Cursors.Arrow;
            tb.PreviewMouseLeftButtonDown += OpenCloseCategory;
            tb.PreviewMouseDoubleClick    += SetEditable;
            tb.LostFocus   += SetUneditable;
            tb.TextChanged += Tb_TextChanged;
            tb.KeyDown     += KeyDownEnter;
            tb.Style        = FindResource("CategoryHover") as Style;

            tb.PreviewMouseMove         += TB_Move;
            tb.PreviewDrop              += TB_Drop;
            tb.PreviewDragEnter         += TB_DragEnter;
            tb.PreviewDragOver          += TB_DragEnter;
            tb.PreviewMouseLeftButtonUp += TB_MouseUp;

            TextBox parent = null;

            foreach (TextBox tb1 in UnCategorised.Children)
            {
                if (tb1.Name == "cate" + noteCategory.category_parent)
                {
                    parent = tb1;
                }
            }
            tb.Tag = parent;

            if (UnCategorised.Children.Count > 0)
            {
                int     count  = 0;
                TextBox loopTB = tb;
                while (loopTB.Tag != null)
                {
                    count++;
                    loopTB = loopTB.Tag as TextBox;
                }
                tb.Margin = new Thickness(count * 10, 3, 0, 0);
                UnCategorised.Children.Insert(UnCategorised.Children.IndexOf(parent) + 1, tb);
            }
            else
            {
                UnCategorised.Children.Add(tb);
            }
        }
Пример #16
0
        /// <summary>
        /// Вспомогательный метод заполнения списка
        /// </summary>
        /// <param name="testTitle"></param>
        /// <param name="tempProject"></param>
        private void InsertNote(string testTitle,
                                Project testProject, NoteCategory testCategory)
        {
            // Делаем паузу между созданием заметок,
            //Чтобы корректно сравнить время
            System.Threading.Thread.Sleep(20);

            var testNote = new Note();

            testNote.Title    = testTitle;
            testNote.Category = testCategory;
            testProject.Notes.Add(testNote);
        }
Пример #17
0
 public ReservationNoteBuilder(Guid id, NoteRequestIndicator sourceNote,
                               NoteCategory category, string additionalNote, bool includeOnConfirmation,
                               ReservationIndicator lodgingReservation, string sourceNoteSubject, bool isFulfilled)
 {
     _id                    = new ReservationNoteIndicator(id);
     _sourceNote            = sourceNote;
     _category              = category;
     _additionalNote        = additionalNote;
     _includeOnConfirmation = includeOnConfirmation;
     _lodgingReservation    = lodgingReservation;
     _sourceNoteSubject     = sourceNoteSubject;
     _isFulfilled           = isFulfilled;
 }
        public static NoteGategoryDTO ToDTO(this NoteCategory entity)
        {
            if (entity is null)
            {
                return(null);
            }

            return(new NoteGategoryDTO()
            {
                Id = entity.Id,
                Name = entity.Name
            });
        }
Пример #19
0
        /// <summary>
        /// Метод фильтрующий список с по выбраной категории.
        /// </summary>
        /// <param name="notes">Список классов.</param>
        /// <param name="noteCategory">Категория заметки.</param>
        /// <returns>Ссылку на отфильтрованый список.</returns>
        public static List <Note> FilterProjectByCategory(List <Note> notes, NoteCategory noteCategory)
        {
            List <Note> newNotes = new List <Note>();

            foreach (var note in notes)
            {
                if (note.Category == noteCategory)
                {
                    newNotes.Add(note);
                }
            }

            return(newNotes);
        }
Пример #20
0
        private void RemoveCategory(String category, int id)
        {
            if (_context.Category.Where(cat => cat.Name == category).Count() == 0)
            {
                return;
            }
            int catID = _context.Category.Where(cat => cat.Name == category).First().CategoryID;

            if (_context.NoteCategory.Where(cat => cat.NoteID == id && cat.CategoryID == catID).Count() != 0)
            {
                NoteCategory toDelete = _context.NoteCategory.Where(cat => cat.NoteID == id && cat.CategoryID == catID).First();
                _context.NoteCategory.Remove(toDelete);
                _context.SaveChanges();
            }
        }
Пример #21
0
    void NotePress(NoteCategory type)
    {
        GameObject note;

        switch (type)
        {
        case NoteCategory.purple:
            note = singleNotePurple;
            break;

        case NoteCategory.orange:
            note = singleNoteOrange;
            break;

        case NoteCategory.cyan:
            note = singleNoteCyan;
            break;

        case NoteCategory.green:
            note = singleNoteGreen;
            break;

        case NoteCategory.yellow:
            note = singleNoteYellow;
            break;

        case NoteCategory.red:
            note = singleNoteRed;
            break;

        case NoteCategory.pink:
            note = singleNotePink;
            break;

        default:
            note = singleNotePurple;
            break;
        }
        note = Instantiate(note, note.transform.position, note.transform.rotation);
        NoteControl noteSpeed = note.GetComponent(typeof(NoteControl)) as NoteControl;

        noteSpeed.speed = 7 * songSpeed;

        if (isRecording)
        {
            RecordNote(type);
        }
    }
Пример #22
0
 private void DragTB(TextBox dragElement, TextBox destination)
 {
     if (dragElement.Name.Substring(0, 4) == "note")
     {
         Note dragNote = DB.GetNote(int.Parse(dragElement.Name.Substring(4)));
         if (destination.Name.Substring(0, 4) == "note")
         {
             Note destNote = DB.GetNote(int.Parse(destination.Name.Substring(4)));
             dragNote.category_id = destNote.category_id;
             DB.Update(dragNote);
         }
         else if (destination.Name.Substring(0, 4) == "cate")
         {
             NoteCategory destCategory = DB.GetNoteCategory(int.Parse(destination.Name.Substring(4)));
             dragNote.category_id = destCategory.category_id;
             DB.Update(dragNote);
         }
         else
         {
             dragNote.category_id = 1;
             DB.Update(dragNote);
         }
     }
     else if (dragElement.Name.Substring(0, 4) == "cate")
     {
         NoteCategory dragCategory = DB.GetNoteCategory(int.Parse(dragElement.Name.Substring(4)));
         if (destination.Name.Substring(0, 4) == "note")
         {
             Note destNote = DB.GetNote(int.Parse(destination.Name.Substring(4)));
             if (dragCategory.category_id != destNote.category_id)
             {
                 dragCategory.category_parent = destNote.category_id;
             }
             DB.Update(dragCategory);
         }
         else if (destination.Name.Substring(0, 4) == "cate")
         {
             NoteCategory destCategory = DB.GetNoteCategory(int.Parse(destination.Name.Substring(4)));
             if (dragCategory.category_id != destCategory.category_id && dragCategory.category_parent != destCategory.category_id)
             {
                 dragCategory.category_parent = destCategory.category_id;
                 DB.Update(dragCategory);
             }
         }
     }
     UpdateNotes();
 }
Пример #23
0
        public ActionResult EditCategory(int id)
        {
            var user = db.Users.Where(x => x.Email == User.Identity.Name).FirstOrDefault();

            ViewBag.Setting   = "active";
            ViewBag.MCategory = "active";


            var catagory = db.NoteCategories.Where(x => x.ID == id).FirstOrDefault();

            NoteCategory noteCategory = new NoteCategory();

            noteCategory.Name        = catagory.Name;
            noteCategory.Description = catagory.Description;

            return(View(noteCategory));
        }
Пример #24
0
        public void TestProjectManagerLoadFromFile_CorrectLoad()
        {
            var          expectedNoteName     = "default name";
            var          expectedNoteContent  = "default content";
            NoteCategory expectedNoteCategory = NoteCategory.Other;

            ProjectData project = new ProjectData();

            project.Notes.Add(new Note("default name", "default content", NoteCategory.Other));
            ProjectManager.SaveToFile(project);

            var actual = ProjectManager.LoadFromFile();

            Assert.AreEqual(expectedNoteName, actual.Notes[0].Name);
            Assert.AreEqual(expectedNoteContent, actual.Notes[0].Content);
            Assert.AreEqual(expectedNoteCategory, actual.Notes[0].Category);
        }
Пример #25
0
        // Кнопки.
        #region Buttons

        private void OkButton_Click(object sender, EventArgs e)
        {
            if (IsEdit)
            {
                CurrentCategory = (NoteCategory)CategoryComboBox.SelectedIndex;
                var CurrentCreationDateTime = CurrentNote.DateOfCreation;
                CurrentNote = new Note(TitleTextBox.Text, ContentTextBox.Text, CurrentCategory);
                CurrentNote.DateOfCreation = CurrentCreationDateTime;
            }
            else
            {
                CurrentCategory = (NoteCategory)CategoryComboBox.SelectedIndex;
                CurrentNote     = new Note(TitleTextBox.Text, ContentTextBox.Text, CurrentCategory);
            }

            DialogResult = DialogResult.OK;
        }
        public ActionResult AddCategory(int?id)
        {
            NoteCategory noteCategory = dbobj.NoteCategories.Find(id);

            if (noteCategory != null)
            {
                AddCategory add = new AddCategory
                {
                    name        = noteCategory.name,
                    Description = noteCategory.Description,
                };
                return(View(add));
            }
            else
            {
                return(View());
            }
            return(View());
        }
Пример #27
0
 private void Tb_TextChanged(object sender, TextChangedEventArgs e)
 {
     editedTitle = sender as TextBox;
     if (editedTitle.Name.Substring(0, 4) == "cate")
     {
         NoteCategory nc = DB.GetNoteCategory(int.Parse(editedTitle.Name.Substring(4)));
         nc.category_title = editedTitle.Text;
         DB.Update(nc);
     }
     else if (editedTitle.Name.Substring(0, 4) == "note")
     {
         Note n = DB.GetNote(int.Parse(editedTitle.Name.Substring(4)));
         if (n != null)
         {
             n.note_title = editedTitle.Text;
             DB.Update(n);
         }
     }
 }
Пример #28
0
        public int AddNote(NoteWithCategories note)
        {
            var oldCategories = _context.Categories
                                .Where(c => note.Categories.Contains(c.Title))
                                .Include(c => c.NoteCategories)
                                .ToList();

            var newCategories = note.Categories
                                .Except(oldCategories.Select(oc => oc.Title));

            var newNote = new Note
            {
                NoteDate    = note.NoteDate,
                Title       = note.Title,
                Description = note.Description,
                IsMarkdown  = note.IsMarkdown
            };

            _context.Add(newNote);
            foreach (var oldCat in oldCategories)
            {
                var newNoteCat = new NoteCategory
                {
                    Note     = newNote,
                    Category = oldCat
                };
                _context.Add(newNoteCat);
            }
            foreach (var newCat in newCategories)
            {
                var newNoteCat = new NoteCategory
                {
                    Note     = newNote,
                    Category = new Category
                    {
                        Title = newCat
                    }
                };
                _context.Add(newNoteCat);
            }
            _context.SaveChanges();
            return(newNote.NoteID);
        }
Пример #29
0
        public async Task <IActionResult> AddNoteCategory(NoteCategory noteCategory)
        {
            if (ModelState.IsValid)
            {
                int          comp_id        = Int32.Parse(HttpContext.User.FindFirst("CompanyID").Value);
                NoteCategory noteCategoryDB = new NoteCategory
                {
                    CompanyID = comp_id,
                    Title     = noteCategory.Title
                };
                await _context.AddAsync(noteCategoryDB);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Notes"));
            }
            ModelState.AddModelError("", "Некорректные данные");
            return(View(noteCategory));
        }
Пример #30
0
        private void AddCategory(String category, int id)
        {
            if (_context.Category.Where(cat => cat.Name == category).Count() == 0)
            {
                Category cat = new Category();
                cat.Name = category;
                _context.Add(cat);
                _context.SaveChanges();
            }
            int catID = _context.Category.Where(cat => cat.Name == category).First().CategoryID;

            if (_context.NoteCategory.Where(cat => cat.NoteID == id && cat.CategoryID == catID).Count() == 0)
            {
                NoteCategory newNCat = new NoteCategory();
                newNCat.CategoryID = catID;
                newNCat.NoteID     = id;
                _context.Add(newNCat);
                _context.SaveChanges();
            }
        }