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)); } }
/// <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); }
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)); } }
// Кнопки. #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; } }
/// <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(); } }
public void DeleteCategory(NoteCategory category) { if (category == null || category.Id == 0) { return; } _categoryRepository.DeleteById(category.Id); }
public void TestCategoryGet_CorrectValue(NoteCategory expected, string message) { _note.NoteCategory = expected; var actual = _note.NoteCategory; Assert.AreEqual(expected, actual, "Геттер категории заметки возвращает неправильную информацию"); Assert.AreEqual(expected, _note.NoteCategory, "Сеттер категории заметки возвращает неправильную информацию"); }
/// <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; }
private Note(string name, NoteCategory category, string text, DateTime created, DateTime modified) { _name = name; _category = category; _text = text; _created = created; _modified = modified; }
private void BtnAddCategory(object sender, RoutedEventArgs e) { NoteCategory nc = new NoteCategory(); nc.category_parent = 1; nc.category_title = "New Category"; DB.Add(nc); UpdateNotes(); }
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")); }
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")); }
private void AddCategories(NoteCategory noteCategory) { foreach (NoteCategory nc in DB.GetNoteCategories()) { if (nc.category_parent == noteCategory.category_id) { CreateNewCategory(nc); AddCategories(nc); } } }
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); } }
/// <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); }
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 }); }
/// <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); }
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(); } }
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); } }
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(); }
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)); }
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); }
// Кнопки. #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()); }
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); } } }
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); }
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)); }
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(); } }