// GET: Edit public ActionResult Edit(int id) { var noteService = CreateNoteService(); var detail = noteService.GetNoteById(id); var viewModel = new EditNoteViewModel { NoteId = detail.NoteId, Title = detail.Title, Content = detail.Content, IsStarred = detail.IsStarred, CategoryId = detail.Category.CategoryId }; var userId = Guid.Parse(User.Identity.GetUserId()); var CategoryService = new CategoryService(userId); var categories = CategoryService.GetCategories(); viewModel.Categories = categories.Select(c => new SelectListItem { Text = c.Name, Value = c.CategoryId.ToString() }); return(View(viewModel)); }
public PartialViewResult Edit(PerformanceMeasureNotePrimaryKey performanceMeasureNotePrimaryKey) { var performanceMeasureNote = performanceMeasureNotePrimaryKey.EntityObject; var viewModel = new EditNoteViewModel(performanceMeasureNote.Note); return(ViewEdit(viewModel)); }
public async Task <IActionResult> EditNote(EditNoteViewModel editNoteViewModel) { if (editNoteViewModel == null) { throw new ArgumentNullException(nameof(editNoteViewModel)); } if (!ModelState.IsValid) { return(View(editNoteViewModel)); } var note = new Note { Id = editNoteViewModel.Id, Description = editNoteViewModel.Description, Title = editNoteViewModel.Title }; var tags = editNoteViewModel .Tags ?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) ?.Select(tag => tag.Trim().ToLower()) ?.ToList(); await _noteRepository.Update(note, tags); return(RedirectToAction( actionName: nameof(NotesController.Index), controllerName: NotesController.Name)); }
public object EditNote(EditNoteViewModel editNoteViewModel) { if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new BaseResponse(ResponseStatus.ValidationError.ToString(), ModelState.Values.ToList()[0].Errors[0].ErrorMessage))); } CurrentUserInfo currentUserInfo = _tokenHelper.GetUserInfo(); if (!_NoteLogic.IsNoteExist(editNoteViewModel.ProjectId, editNoteViewModel.NoteId)) { return(Request.CreateResponse(HttpStatusCode.NotFound, new BaseResponse(ResponseStatus.Notfound.ToString(), ResponseMessagesModel.DailyActiviyNotFound))); } if (_projectLogic.GetUserRoleInProject(currentUserInfo.Id, editNoteViewModel.ProjectId) == UserRole.Collaborator && !_NoteLogic.IsNoteCreatedBy(currentUserInfo.Id, editNoteViewModel.NoteId)) { return(Request.CreateResponse(HttpStatusCode.MethodNotAllowed, new BaseResponse(ResponseStatus.ValidationError.ToString(), ResponseMessagesModel.PermissionDenied))); } NoteData NoteData = EditNoteViewModel.GetNoteData(editNoteViewModel); _NoteLogic.Edit(NoteData); return(Request.CreateResponse(HttpStatusCode.OK, new BaseResponse(ResponseStatus.Success.ToString(), ResponseMessagesModel.Success))); }
public IActionResult EditNote(int NoteId, int BurialId) { Notes note = _context.Notes.Where(b => b.NotesId == NoteId).FirstOrDefault(); EditNoteViewModel editViewModel = new EditNoteViewModel(_context, NoteId, BurialId); return(View(editViewModel)); }
public async Task <IActionResult> EditNote(EditNoteViewModel model) { if (!this.ModelState.IsValid) { return(View(nameof(Edit), model)); } if (model.SelectedCategoryId == 0) { model.SelectedCategoryId = null; } try { await _notesService.EditAsync(model.Note.Id, model.Note.Text, model.SelectedCategoryId, model.Note.IsCompleted, model.Note.HasStatus); return(RedirectToAction(nameof(Notes), new { entityId = model.Note.EntityId })); } catch (ApplicationException ex) { model.ErrorMessage = ex.Message; return(View(nameof(Edit), model)); } }
public PartialViewResult Edit(ObligationRequestSubmissionNotePrimaryKey obligationRequestNotePrimaryKey) { var obligationRequestNote = obligationRequestNotePrimaryKey.EntityObject; var viewModel = new EditNoteViewModel(obligationRequestNote.Note); return(ViewEdit(viewModel)); }
private void Load(Book book, Note note = null) { InitializeComponent(); vm = new EditNoteViewModel(this, book, note); this.DataContext = vm; }
public async Task <IActionResult> SaveChangesNoteAsync(EditNoteViewModel editNoteViewModel) { var note = await _context.Notes.FindAsync(editNoteViewModel.Id); note.Header = editNoteViewModel.Header; note.Text = editNoteViewModel.Text; note.DateLastChanged = DateTime.Now; try { _context.Entry(note).State = EntityState.Modified; } catch (Exception e) { Debug.WriteLine(e.Message); } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(editNoteViewModel.Id)) { return(RedirectToAction("Index", "Index")); } throw; } return(RedirectToAction("Index", "Index")); }
// GET: Note/Edit/5 public ActionResult Edit(int?id, string returnUrl) { var user = db.GetUserByID(GetUserId()); Note note = db.GetNoteByID(id); if (note == null) { return(HttpNotFound()); } var model = new EditNoteViewModel { Id = note.Id, Title = note.Title, IntervalInDays = note.IntervalInDays, DueDate = note.DueDate.ToLocalTime(user), FirstStudiedDate = note.FirstStudiedDate.ToLocalTime(user), Notebook = note.Notebook, TimeEstimate = note.TimeEstimate, Resources = note.Resources?.ToArray(), ReturnUrl = returnUrl, Notebooks = GetNotebooks() }; return(View(model)); }
public PartialViewResult Edit(ProjectNoteUpdatePrimaryKey projectNoteUpdatePrimaryKey) { var projectNoteUpdate = projectNoteUpdatePrimaryKey.EntityObject; var viewModel = new EditNoteViewModel(projectNoteUpdate.Note); return(ViewEdit(viewModel)); }
protected override async void OnAppearing() { var viewModel = new EditNoteViewModel(_noteId); await viewModel.LoadData(); BindingContext = viewModel; base.OnAppearing(); }
public IActionResult Edit(EditNoteViewModel model) { var note = this.mapper.Map <Note>(model); this.notesService.EditNote(note); return(this.RedirectToAction(nameof(this.All))); }
public ActionResult EditNote(int id) { ViewBag.Class = "white-nav"; ViewBag.SellNotes = "active"; //fetch data var category = db.NoteCategories.Where(x => x.IsActive == true).ToList(); var type = db.NoteTypes.Where(x => x.IsActive == true).ToList(); var country = db.Countries.Where(x => x.IsActive == true).ToList(); var user = db.Users.FirstOrDefault(x => x.Email == User.Identity.Name); var note = db.SellerNotes.Where(x => x.ID == id && x.SellerID == user.ID && x.Status == 6).FirstOrDefault(); var FileNote = db.SellerNotesAttachements.Where(x => x.NoteID == note.ID && x.IsActive == true).ToList(); string path = ""; //fetch all file name foreach (var item in FileNote) { path = path + item.FileName + ", "; //all file name } //if someone access othe file if (note == null) { return(Content("You can't have access to this file")); } EditNoteViewModel editnote = new EditNoteViewModel(); editnote.NoteCategoryList = category; editnote.NoteTypeList = type; editnote.CountryList = country; editnote.Title = note.Title; editnote.Category = note.Category; editnote.NoteType = note.NoteType; editnote.NumberofPages = note.NumberofPages; editnote.Description = note.Description; editnote.Country = note.Country; editnote.UniversityName = note.UniversityName; editnote.Course = note.Course; editnote.CourseCode = note.CourseCode; editnote.Professor = note.Professor; editnote.IsPaid = note.IsPaid; editnote.SellingPrice = note.SellingPrice; editnote.DisplayPicturePathName = note.DisplayPicture; editnote.NotePreviewPathName = note.NotesPreview; //editnote.NotePathName = path; ViewBag.ImageName = Path.GetFileName(note.DisplayPicture); ViewBag.PreviewName = Path.GetFileName(note.NotesPreview); //ViewBag.FileName = path; return(View(editnote)); }
public EditNoteCommand(EditNoteViewModel editNoteViewModel, MainWindowViewModel mainWindowViewModel) { _updateViewCommand = new UpdateViewCommand(mainWindowViewModel); _editNoteViewModel = editNoteViewModel; _mainWindowViewModel = mainWindowViewModel; _editNoteViewModel.PropertyChanged += ViewModel_PropertyChanged; }
public ActionResult Edit(int id, int customerId) { var model = new EditNoteViewModel(); prepareEditModel(model, id, customerId); model.Note = NoteService.FindNoteModel(id, model.CurrentCompany, customerId, NoteType.Customer); model.LGS = NoteService.LockNote(model.Note); return(View("EditNote", model)); }
public ActionResult Edit(ProjectNotePrimaryKey projectNotePrimaryKey, EditNoteViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEdit(viewModel)); } var projectNote = projectNotePrimaryKey.EntityObject; viewModel.UpdateModel(projectNote, CurrentFirmaSession); return(new ModalDialogFormJsonResult()); }
private void UpdateNote(Note note, EditNoteViewModel model) { var user = db.GetUserByID(GetUserId()); note.Title = model.Title; note.Notebook = model.Notebook; note.IntervalInDays = model.IntervalInDays; note.DueDate = model.DueDate.FromLocalTime(user); note.FirstStudiedDate = model.FirstStudiedDate.FromLocalTime(user); note.TimeEstimate = model.TimeEstimate; UpdateNoteResources(note, model); }
public MainWindowViewModel() { WebServise = new WebServise(); loginViewModel = new LoginViewModel(this); signUpViewModel = new SignUpViewModel(this); userPageViewModel = new UserPageViewModel(this); addNewNoteViewModel = new AddNewNoteViewModel(this); editNoteViewModel = new EditNoteViewModel(this); SelectedViewModel = loginViewModel; }
public ActionResult New(ProjectPrimaryKey projectPrimaryKey, EditNoteViewModel viewModel) { if (!ModelState.IsValid) { return(ViewEdit(viewModel)); } var project = projectPrimaryKey.EntityObject; var projectInternalNote = ProjectInternalNote.CreateNewBlank(project); viewModel.UpdateModel(projectInternalNote, CurrentFirmaSession); HttpRequestStorage.DatabaseEntities.AllProjectInternalNotes.Add(projectInternalNote); return(new ModalDialogFormJsonResult()); }
public ActionResult Edit(EditNoteViewModel model) { if (ModelState.IsValid) { Note note = db.GetNoteByID(model.Id); UpdateNote(note, model); db.UpdateNote(note); db.SaveChanges(); TempData["successMsg"] = $"Successfully updated the note \"{note.Title}\"."; return(Redirect(model.ReturnUrl)); } TempData["errorMsg"] = "Failed to update note. Invalid data."; return(View(model)); }
public async Task <IActionResult> Edit(int noteId) { var note = (await _notesService.GetByIdAsync(noteId)); string userId = GetLoggedUserId(); EditNoteViewModel model = new EditNoteViewModel { Note = ConvertNoteDtoToNoteViewModel(note, userId), EntityCategories = await GetEntityCategoriesAsync(note.EntityId), SelectedCategoryId = note.Category?.CategoryId }; return(View(nameof(Edit), model)); }
public ActionResult Edit(EditNoteViewModel model) { if (!ModelState.IsValid) { return(View()); } notes.Update(model.Note); notes.SaveChanges(); notes.Dispose(); return(RedirectToAction("Index")); }
// GET public async Task <IActionResult> EditNote(string idNote) { var note = await _context.Notes.FindAsync(new Guid(idNote)); var model = new EditNoteViewModel() { Id = note.Id, Header = note.Header, Text = note.Text, DateCreated = note.DateCreated, DateLastChanged = note.DateLastChanged, IdUser = note.IdUser }; return(View(model)); }
public ActionResult Save(EditNoteViewModel model, string command) { if (command.ToLower() == "save") { var modelError = NoteService.InsertOrUpdateNote(model.Note, CurrentUser, model.LGS); if (modelError.IsError) { prepareEditModel(model, model.CurrentCompany.Id, model.Note.ParentId); model.SetErrorOnField(ErrorIcon.Error, modelError.Message, "Note_" + modelError.FieldName); return(View("EditNote", model)); } } return(RedirectToAction("CustomerNotes", new { id = model.ParentId })); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { IDictionary <string, string> parameters = this.NavigationContext.QueryString; if (parameters.ContainsKey("NoteId")) { NoteId = parameters["NoteId"]; } if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New) { editNoteViewModel = new EditNoteViewModel(Int32.Parse(NoteId), this); this.DataContext = editNoteViewModel; } base.OnNavigatedTo(e); }
public async Task Edit(EditNoteViewModel note) { using var scope = TransactionFactory.New(); var noteFromDatabase = await Get(note.Id); noteFromDatabase.Title = note.Title; noteFromDatabase.Description = note.Description; noteFromDatabase.Status = (Status)note.Status; noteFromDatabase.UpdatedAt = DateTimeOffset.Now; _context.Notes.Update(noteFromDatabase); await _context.SaveChangesAsync(); scope.Complete(); }
void prepareEditModel(EditNoteViewModel model, int id, int customerId) { var customer = CustomerService.FindCustomerModel(customerId, CurrentCompany); string title = EvolutionResources.bnrAddEditCustomerNote + (customer == null ? "" : " - " + customer.Name); if (id <= 0) { title += " - " + EvolutionResources.lblNewNote; } PrepareViewModel(model, title, customerId, MakeMenuOptionFlags(customerId, 0)); model.ParentId = customerId; model.MaxUploadFileSize = GetMaxFileUploadSize(); model.ValidFileTypes = MediaServices.GetValidMediaTypes(); }
public async Task <IActionResult> Edit(EditNoteViewModel noteViewModel) { try { if (ModelState.IsValid) { var noteToBeUpdated = await _notesService.GetNoteById(noteViewModel.Id); await _notesService.UpdateNote(noteToBeUpdated, _mapper.Map <NoteModel>(noteViewModel)); return(RedirectToAction("Index")); } } catch { } return(View("Index", noteViewModel)); }
public async Task <IActionResult> EditNote(EditNoteViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var user = await _userManager.FindByNameAsync(User.Identity?.Name); if (user is null) { return(Unauthorized()); } var tags = viewModel .Tags ?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) ?.Select(tag => tag.Trim().ToLowerInvariant()) ?.ToList() ?? Enumerable.Empty <string>().ToList(); var note = new Note { Id = viewModel.Id, Description = viewModel.Description, Tags = string.Join(',', tags), Title = viewModel.Title, UserId = user.Id }; var success = await _noteDao.SaveNote(note); if (!success) { ModelState.AddModelError("", "Edit note failed due to unexpected error"); return(View(viewModel)); } return(RedirectToAction( actionName: nameof(NotesController.Index), controllerName: NotesController.Name)); }