public HttpResponseMessage EditNote(EditNote editNote, [ValueProvider(typeof(HeaderValueProviderFactory <string>))] string authKey) { HttpResponseMessage responseMessage; User sqlUser; if (!ValidateCredentials.AuthKeyIsValid(db, authKey, out sqlUser)) { responseMessage = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid information."); return(responseMessage); } MongoCollection <Note> notesCollection = mongoDb.GetCollection <Note>(MongoCollections.Notes); Note foundNote = notesCollection.FindOneAs <Note>(Query.EQ("_id", new ObjectId(editNote.Id))); MongoCollection <UsersProjects> usersInProjects = mongoDb.GetCollection <UsersProjects>(MongoCollections.UsersInProjects); // todo projects need to be recognized by id UsersProjects postingUser = usersInProjects.AsQueryable <UsersProjects>() .FirstOrDefault(x => x.Username == sqlUser.Username && x.ProjectName == foundNote.ProjectName); if (postingUser == null) { responseMessage = this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User does not participate in project."); return(responseMessage); } foundNote.Text = editNote.Text; notesCollection.Save(foundNote); return(responseMessage = this.Request.CreateResponse(HttpStatusCode.OK, new { Note = foundNote })); }
public async Task <GenericResponse <bool> > Edit(EditNote editData) { var responseBuilder = _responseBuilderFactory.GetResponseBuilder <bool>(); try { Note noteToEdit; var noteResult = await _mongoNoteCollection.FindAsync(Builders <Note> .Filter.Eq("Id", editData.Id)); noteToEdit = noteResult.First(); if (noteToEdit != null) { noteToEdit.DateOfModification = DateTime.UtcNow; noteToEdit.NoteText = editData.NoteText; noteToEdit.Shared = editData.Shared; noteToEdit.NoteTitle = editData.NoteTitle; return(responseBuilder.WithEntity(true).WithStatusCode(StatusCodes.Success).WithMessage("OK") .GetObject()); } return(responseBuilder.WithEntity(false).WithStatusCode(StatusCodes.NotFound).WithMessage("Cannot find note with ID:" + editData.Id) .GetObject()); } catch (Exception e) { return(responseBuilder.WithEntity(false).WithStatusCode(StatusCodes.NotFound).WithMessage(e.ToString()) .GetObject()); } }
//edit desc public void EditNoteApplication() { EditNote.ClickWait(); NoteDescription.EnterClearText("Description" + RandomNumber.smallNumber()); ConfirmCreateNote.ClickOn(); softAssert.VerifySuccessMsg(); }
public void Command_must_contain__SchoolId_NoteId_and_Content() { var school = new SchoolAggregate(SchoolId.With(default(Guid))); var author = new ApplicationUser(); var command = new EditNote.Command() { SchoolId = default, NoteId = default, Content = " "
public void editNote(string b = null, string c = null) { EditNote editNote = new EditNote(); editNote.Location = new System.Drawing.Point(400, 100); editNote.setValue(b, c); this.Controls.Add(editNote); editNote.BringToFront(); }
public void When(EditNote c) { NoteItem item; if (!_state.TryGet(c.NoteId, out item)) { throw Error("Note {0} does not exist", c.NoteId); } Apply(new NoteEdited(c.NoteId, c.Text, c.OldText, item.Story)); }
public async Task <IActionResult> Edit(string id, EditNote editNote) { if (string.IsNullOrWhiteSpace(id)) { return(NotFound()); } var oldNote = await _noteService.FindOne(id); if (oldNote == null) { return(NotFound()); } if (ModelState.IsValid) { var note = editNote.ToNote(ref oldNote); await _noteService.Update(note); return(RedirectToAction("Details", new { id })); } return(View(editNote)); }
public async Task <GenericResponse <bool> > Edit(EditNote editData) { var responseBuilder = _responseBuilderFactory.GetResponseBuilder <bool>(); Note noteToEdit; lock (Lockobject) { noteToEdit = NoteDatabase.SingleOrDefault(x => x.Id == editData.Id); } if (noteToEdit != null) { lock (Lockobject) { noteToEdit.DateOfModification = DateTime.UtcNow; noteToEdit.NoteText = editData.NoteText; noteToEdit.Shared = editData.Shared; noteToEdit.NoteTitle = editData.NoteTitle; } return(responseBuilder.WithEntity(true).WithStatusCode(StatusCodes.Success).WithMessage("OK") .GetObject()); } return(responseBuilder.WithEntity(false).WithStatusCode(StatusCodes.NotFound).WithMessage("Cannot find note with ID:" + editData.Id) .GetObject()); }