public IActionResult Edit(NoteVM noteVM) { if (noteVM.Note == null) { return(NotFound()); } if (ModelState.IsValid) { Note newNote = noteVM.Note; _db.Note.Remove(_db.Note.Find(newNote.Id)); _db.RemoveRange(_db.NoteTag.Where(i => i.NotesId == newNote.Id)); if (noteVM.NoteTags != null) { foreach (var t in _db.Tag) { if (noteVM.NoteTags.Contains(t.Id)) { NoteTag noteTag = new NoteTag { NotesId = newNote.Id, TagsId = t.Id }; newNote.NoteTags.Add(noteTag); } } } _db.Add(newNote); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(noteVM)); }
public IActionResult Create(NoteVM noteVM) { if (ModelState.IsValid) { Note newNote = noteVM.Note; if (noteVM.NoteTags != null) { foreach (var t in _db.Tag) { if (noteVM.NoteTags.Contains(t.Id)) { NoteTag noteTag = new NoteTag { NotesId = newNote.Id, TagsId = t.Id }; newNote.NoteTags.Add(noteTag); } } } _db.Note.Add(newNote); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(noteVM)); }
//GET - EDIT public IActionResult Edit(int?id) { if (id == null || id == 0) { return(NotFound()); } NoteVM noteVM = new NoteVM() { Note = _db.Note.Find(id), TagSelectList = new List <SelectListItem>(), NoteTags = _db.NoteTag.Where(i => i.NotesId == id).Select(sc => sc.TagsId) }; foreach (Tag t in _db.Tag) { noteVM.TagSelectList.Add( new SelectListItem { Text = t.Name, Value = t.Id.ToString() }); } if (noteVM.Note == null) { return(NotFound()); } return(View(noteVM)); }
public void InsertNote(NoteVM noteVM, out BaseInfo baseReturn) { baseReturn = new BaseInfo(); var newNote = _mapper.Map <NoteVM, Notes>(noteVM); newNote.NoteDetails = _mapper.Map <NoteVM, NoteDetails>(noteVM); newNote.CreateDate = newNote.LastUpdateDate = DateTime.Now; newNote.NoteID = newNote.NoteDetails.NoteID = Guid.NewGuid().ToString("D").ToUpper() + "_" + DateTime.Now.ToString("yyyyMMdd"); try { if (this.CheckPhotoIsExist(noteVM.NotePhoto)) { baseReturn.returnMsgNo = -2; baseReturn.returnMsg = "照片新增重複。"; return; } _unitOfWork.NotesRepository.Insert(newNote); _unitOfWork.SaveChanges(); } catch (Exception ex) { baseReturn.returnMsgNo = -1; baseReturn.returnMsg = "新增失敗。"; return; } baseReturn.returnMsgNo = 1; baseReturn.returnMsg = "新增成功!"; return; }
public Note(NoteVM note, string userId) { ModifyTo(note); UserId = userId; NumOfVisits = 1; CreateDate = DateTime.Now; }
//Đã check public NoteWindow() { InitializeComponent(); viewModel = new NoteVM(); container.DataContext = viewModel; viewModel.SelectedNoteChanged += ViewModel_SelectedNoteChanged; viewModel.SelectedNotebookChanged += ViewModel_SelectedNotebookChanged; var currentCulture = (from r in SpeechRecognitionEngine.InstalledRecognizers() where r.Culture.Equals(Thread.CurrentThread.CurrentCulture) select r).FirstOrDefault(); recognizer = new SpeechRecognitionEngine(currentCulture); GrammarBuilder builder = new GrammarBuilder(); builder.AppendDictation(); Grammar grammar = new Grammar(builder); recognizer.LoadGrammar(grammar); // đặt thiết bị input là thiết bị mình default trong maý recognizer.SetInputToDefaultAudioDevice(); recognizer.SpeechRecognized += Recognizer_SpeechRecognized; //sẽ trả về 1 list font var fontFamilies = Fonts.SystemFontFamilies.OrderBy(f => f.Source); fontFamilyComboBox.ItemsSource = fontFamilies; //sẽ trả về 1 list font chữ. Nhưng Combobox này có thể chỉnh số bên trong được đã được định nghĩa trong file xmal List <double> fontSizes = new List <double>() { 8, 9, 10, 11, 12, 14, 28, 48, 72 }; fontSizeComboBox.ItemsSource = fontSizes; }
public static void UpdateNote(this Note note, NoteVM noteVM) { note.Title = noteVM.Title; note.Description = noteVM.Description; note.Finished = noteVM.Finished; note.Timestamp = noteVM.Timestamp; note.NotebookId = noteVM.NotebookId; }
public AddNote(int eleveId) { InitializeComponent(); DataContext = new NoteVM(new Note() { EleveId = eleveId, DateNote = DateTime.Now }, this); }
private async void FavSelected(NoteVM note) { var notePage = new NotePage() { BindingContext = note }; await Navigation.PushAsync(notePage); }
public void ContinueTask(NoteVM noteVM) { var updatedNote = noteFactory.ResumedTask(noteVM.Model); var updatedVM = CreateNoteVM(updatedNote); runningNoteVM = updatedVM; runningNoteVM.UpdateDuration(TimeSpan.Zero);// will immediately display a counter PlaceToLast(updatedVM, noteVM); }
public void CreateTask(string text) { var note = noteFactory.CreateTask(text, timeProvider.Now); var noteVM = CreateNoteVM(note); runningNoteVM = noteVM; runningNoteVM.UpdateDuration(TimeSpan.Zero);// will immediately display a counter PlaceToLast(noteVM); }
public void CreateNote(string text) { var note = noteFactory.CreateNote(text, timeProvider.Now); var noteVM = new NoteVM { Model = note }; PlaceToLast(noteVM); }
private NoteVM CreateNoteVM(Note model) { var result = new NoteVM { Model = model }; result.ToggleRunningStateRequested += OnNoteToggleRunningStateRequested; return(result); }
// go to the note editing form public IActionResult Edit(int id) { List <NoteVM> listOfNotes = JsonConvert.DeserializeObject <List <NoteVM> >(ReadJsonFile()); NoteVM note = (from n in listOfNotes where n.Id == id select n).First(); return(View(note)); }
public async Task <ActionResult <Note> > PostNote(int gameId, NoteVM noteVM) { var noteEntity = _context.Notes.Add(new Note()); noteEntity.CurrentValues.SetValues(noteVM); noteEntity.Entity.GameId = gameId; await _context.SaveChangesAsync(); return(Ok(noteEntity.Entity)); }
public JsonResult IsExpectedBirthYear(int birthYear) { var throwError = true; if (Request.UrlReferrer != null && Request.UrlReferrer.OriginalString.Contains("Create")) { throwError = NoteVM.Check(birthYear); } return(Json(throwError, JsonRequestBehavior.AllowGet)); }
public void EditNote(NoteVM model) { Note noteToEdit = db.Notes.Where(x => x.Id.Equals(model.Id)).FirstOrDefault(); noteToEdit.Title = model.Title; noteToEdit.Text = model.Text; noteToEdit.ColorId = model.ColorId; noteToEdit.CreatedAt = DateTime.Now; db.SaveChanges(); }
public ActionResult Delete(Guid id, FormCollection collection) { if (NoteVM.Remove(id)) { return(RedirectToAction("Index")); } else { ViewBag.Error = "Error occurred while processing your request"; return(View(NoteVM.Get(id))); } }
// GET: Note public ActionResult Index() { NoteVM noteVM = new NoteVM(); noteVM.NoteEntries = noteEntryService.GetActiveNote(); noteVM.ClassRooms = classRoomService.GetActiveRoom(); noteVM.Teachers = teacherService.GetActiveTeacher(); noteVM.PeriodInformations = periodInformationService.GetActivePeriodInformation(); noteVM.Students = studentService.GetActiveStudent(); noteVM.Lessons = lessonService.GetActiveLesson(); return(View(noteVM)); }
private void PlaceToLast(NoteVM newNote, NoteVM oldNote = null) { if (oldNote != null) { int index = Notes.IndexOf(oldNote); Notes.RemoveAt(index); oldNote.ToggleRunningStateRequested -= OnNoteToggleRunningStateRequested; } Notes.Add(newNote); GroupNotesByDate(); OnPropertyChanged(nameof(Notes)); ItemsPositionChanged?.Invoke(this, EventArgs.Empty); }
public void StopTask(TimeSpan elapsedTimer) { var timeStopped = timeProvider.Now; var noteVM = Notes.SingleOrDefault(n => n.Model.State == NoteState.TimerRunning); if (noteVM != null) { var updatedNote = noteFactory.StoppedTask(noteVM.Model, timeStopped, elapsedTimer); var updatedVM = CreateNoteVM(updatedNote); runningNoteVM = null; PlaceToLast(updatedVM, noteVM); //TODO update in place (there may be notes below) } }
public IActionResult Delete(NoteVM model) { List <NoteVM> listOfNotes = JsonConvert.DeserializeObject <List <NoteVM> >(ReadJsonFile()); // find note with needed id and delete it NoteVM note = (from n in listOfNotes where n.Id == model.Id select n).First(); listOfNotes.Remove(note); WriteJsonFile(JsonConvert.SerializeObject(listOfNotes)); return(RedirectToAction("GetAllNotes")); }
public ActionResult <NoteVM> Post([FromBody] NoteVM data) { if (!ModelState.IsValid) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } else { Note newNote = new Note(); newNote.UpdateNote(data); _noteService.Add(newNote); _noteService.Save(); return(Mapper.Map <NoteVM>(newNote)); } }
// /Home/addNoteAjax public PartialViewResult addNote(NoteVM model) { //Adding note code goes here Note note = new Note(); note.Title = model.Title; note.Text = model.Text; note.ColorId = model.ColorId; note.CreatedAt = DateTime.Now; db.Notes.Add(note); db.SaveChanges(); return(PartialView("_NoteThumbnailsPartial", db.Notes.ToArray().Select(x => new NoteVM(x)).ToList())); }
public ActionResult <NoteVM> Put(int id, [FromBody] NoteVM data) { if (id != (int)data.Id || !ModelState.IsValid) { return(new StatusCodeResult((int)HttpStatusCode.BadRequest)); } var note = _noteService.GetById(id); note.UpdateNote(data); _noteService.Update(note); _noteService.Save(); return(Mapper.Map <NoteVM>(note)); }
public ActionResult Create(NoteVM noteVM) { if (!ModelState.IsValid) { return(View(noteVM)); } if (NoteVM.Add(noteVM)) { return(RedirectToAction("Index")); } else { ViewBag.Error = "Error occurred while processing your request"; return(View(noteVM)); } }
public IHttpActionResult UpdateNote(NoteVM model) { // 取得用戶資料 BaseInfo baseReturn; string guestID = UserInformationHelper.GetUserGuestID(); model.GuestID = guestID; _noteService.UpdateNote(model, out baseReturn); if (baseReturn.returnMsgNo != 1) { return(BadRequest(baseReturn.returnMsg)); } return(Ok(baseReturn)); }
// GET: api/ManageEmployeeNoteAPI public IQueryable <NoteVM> GetNotes(int empId) { var notes = from n in db.Note where n.EmployeeID == empId select n; List <NoteVM> nvs = new List <NoteVM>(); foreach (var note in notes) { NoteVM nv = new NoteVM(); nv.EmployeeID = note.EmployeeID; nv.NoteID = note.NoteID; nv.Description = note.Description; nvs.Add(nv); } return(nvs.AsQueryable()); }
public IHttpActionResult GetNote(int empId, int id) { Note note = db.Note.Find(id); if (note == null) { return(NotFound()); } NoteVM nv = new NoteVM(); nv.EmployeeID = note.EmployeeID; nv.NoteID = note.NoteID; nv.Description = note.Description; return(Ok(nv)); }
public IHttpActionResult PostNote(Note note) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Note.Add(note); db.SaveChanges(); NoteVM nv = new NoteVM(); nv.EmployeeID = note.EmployeeID; nv.NoteID = note.NoteID; nv.Description = note.Description; return(CreatedAtRoute("DefaultApi", new { id = nv.NoteID }, nv)); }