public async Task EditPost(EditPost createPost, int postId) { var post = await _postRepository.GetPost(postId); post.EditPost(createPost.OfferDescription, createPost.OfferCountry, createPost.OfferCity, createPost.OfferCost, createPost.HotelName, createPost.DeparturePlace, createPost.DateOfDeparture, createPost.DateOfReturn, createPost.IsActivePost, createPost.IsBannedPost, createPost.OfferPhotoHref); await _postRepository.EditPost(post); }
private void EditPost(object sender, RoutedEventArgs e) { EditPost window = new EditPost(_current_post.Id); window.ShowDialog(); Refresh(); }
public void CancleEditButtonFuntionality() { HomePage homePage = new HomePage(this.driver); homePage.NavigateTo(); LoginPage logPage = new LoginPage(this.driver); logPage.NavigateTo(); var loginUser = AccessExcelData.GetTestDataLoging("LoginSuccessfully"); logPage.FillLoginForm(loginUser); homePage.EditPostLink.Click(); EditPost editPage = new EditPost(this.driver); var postUser = AccessExcelData.GetTestDataPosts("CancelButtonEditPost").ToString(); editPage.EditButton.Click(); editPage.TitleToEdit.Clear(); editPage.TitleToEdit.SendKeys(postUser); editPage.ContentToEdit.Clear(); editPage.ContentToEdit.SendKeys(postUser); editPage.CancelButtonPost.Click(); editPage.AssertPostEditCancelButton("Test Post Creation"); }
public void EditPostContentResize() { HomePage homePage = new HomePage(this.driver); homePage.NavigateTo(); LoginPage logPage = new LoginPage(this.driver); logPage.NavigateTo(); var loginUser = AccessExcelData.GetTestDataLoging("LoginSuccessfully"); logPage.FillLoginForm(loginUser); homePage.EditPostLink.Click(); EditPost editPage = new EditPost(this.driver); var postUser = AccessExcelData.GetTestDataPosts("EditPostSuccessfuly").ToString(); editPage.EditButton.Click(); editPage.TitleToEdit.Clear(); editPage.TitleToEdit.SendKeys(postUser); Actions builder = new Actions(this.driver); var action = builder.MoveToElement(editPage.ContentToEdit) .MoveByOffset((editPage.ContentToEdit.Size.Width / 2) - 2, (editPage.ContentToEdit.Size.Height / 2) - 2) .ClickAndHold() .MoveByOffset(300, 300) .Release(); action.Perform(); editPage.AssertEditPageIsDisplayed("Edit Article"); editPage.AssertComtentResizeField(300); }
public Post EditPost([FromRoute(Name = "post_id")] int postId, EditPost editPost) { var user = GetAuthorizedUser(); var post = GetPost(postId); if (!post.IsAuthor(user)) { throw new StatusException(StatusCodes.Status403Forbidden, $"User '{user.Username}' lacks permission to edit post '{post.Id}'"); } if (editPost.IsFieldSet(nameof(editPost.Title))) { if (editPost.Title == null) { throw new StatusException(StatusCodes.Status422UnprocessableEntity, "Failed to validate field title: can't be null"); } post.Title = editPost.Title; } if (editPost.IsFieldSet(nameof(editPost.Content))) { post.Content = editPost.Content; } if (editPost.IsFieldSet(nameof(editPost.Url))) { post.Url = editPost.Url; } post.Edited = DateTime.UtcNow; Db.SaveChanges(); return(post); }
public bool SavePost(EditPost editPost, int?id) { Post post = null; if (id.HasValue) { post = _dbContext.Posts.Include(g => g.Tags).FirstOrDefault(g => g.Id == id.Value); } else { post = new Post(); _dbContext.Posts.Add(post); } if (post == null) { return(false); } post.Update(editPost); _dbContext.SaveChanges(); editPost.Id = post.Id; return(true); }
private void MenuEdit_Click(object sender, RoutedEventArgs e) { var menuItem = (MenuItem)sender; var contextMenu = (ContextMenu)menuItem.Parent; var item = (DataGrid)contextMenu.PlacementTarget; var selectedPost = (Post)item.SelectedCells[0].Item; var window = new EditPost(Connector, ref selectedPost); window.ShowDialog(); dgPosts.Items.Refresh(); }
private void EditPost() { if (CurrentPost != null && CurrentPost.UserId == StateHolder.CurrentUser.Id) { var result = new EditPost() { DataContext = new EditPostVM(CurrentPost) }.ShowDialog(); if (result == true) { RefreshList(); } } }
public void UpdatePost_Test() { // arrange mockRepo.Setup(repo => repo.Posts.FindByCondition(u => u.ID == It.IsAny <int>())).Returns(GetPosts()); EditPost potentialPost = new EditPost() { ID = 2, Type = "Looking for player", Platform = "Xbox", PlayerRating = "82", Position = "GK", Description = "test description" }; // act var controllerJsonResult = postController.UpdatePost(potentialPost); // assert Assert.NotNull(controllerJsonResult); Assert.IsType <JsonResult>(controllerJsonResult); }
public ActionResultStatus EditPostWithoutPhoto(EditPost editPost) { using var transaction = dBContext.Database.BeginTransaction(); try { dBContext.Posts.Update(editPost.post); dBContext.SaveChanges(); dBContext.PhotoParams.Update(editPost.photoParam); dBContext.SaveChanges(); transaction.Commit(); return(ActionResultStatus.Success); } catch (Exception ex) { transaction.Rollback(); Logger.LogError(ex.Message, ex); return(ActionResultStatus.Error); } }
public JsonResult UpdatePost(EditPost post) { var postToUpdate = repository.Posts.FindByCondition(p => p.ID == post.ID).FirstOrDefault(); if (postToUpdate == null) { _logger.LogInformation("Post ID not found"); return(new JsonResult("No user to edit")); } postToUpdate.Type = post.Type; postToUpdate.Platform = post.Platform; postToUpdate.Position = post.Position; postToUpdate.PlayerRating = post.PlayerRating; postToUpdate.Description = post.Description; repository.Posts.Update(postToUpdate); _logger.LogInformation($"About to save {postToUpdate.ID} with new position {postToUpdate.Position}"); repository.Save(); _logger.LogInformation("Post updated!"); return(new JsonResult("Post Updated!")); }
public static void Main(string[] args) { int menuSelection = 0; while (menuSelection != 6) { if (menuSelection == 1) { IViewPost readObject = new ViewPost(); List <Post> allPosts = readObject.ViewPost(); foreach (Post post in allPosts) { Console.WriteLine(post.ToString()); } } else if (menuSelection == 2) { ISavePost savePost = new SavePost(); savePost.SavePost(); } else if (menuSelection == 3) { IDeletePost deletePost = new DeletePost(); deletePost.DeletePost(); } else if (menuSelection == 4) { IEditPost editPost = new EditPost(); editPost.EditPost(); } else if (menuSelection == 5) { IReseedPost reseedPost = new ReseedPost(); reseedPost.ReseedPost(); } menuSelection = displayMenu(); } }
public void WithoutContentPostEdit() { HomePage homePage = new HomePage(this.driver); homePage.NavigateTo(); LoginPage logPage = new LoginPage(this.driver); logPage.NavigateTo(); var loginUser = AccessExcelData.GetTestDataLoging("LoginSuccessfully"); logPage.FillLoginForm(loginUser); homePage.EditPostLink.Click(); EditPost editPage = new EditPost(this.driver); var postUser = AccessExcelData.GetTestDataPosts("EditPostWithoutContent"); editPage.NavigateTo(); editPage.FillEditPostForm(postUser); editPage.AssertErrorMessageForEmptyFieldsPostEdit("The Content field is required."); }
public void EditPostSuccessfuly() { HomePage homePage = new HomePage(this.driver); homePage.NavigateTo(); LoginPage logPage = new LoginPage(this.driver); logPage.NavigateTo(); var loginUser = AccessExcelData.GetTestDataLoging("LoginSuccessfully"); logPage.FillLoginForm(loginUser); homePage.EditPostLink.Click(); EditPost editPage = new EditPost(this.driver); var postUser = AccessExcelData.GetTestDataPosts("EditPostSuccessfuly"); editPage.NavigateTo(); editPage.FillEditPostForm(postUser); editPage.AssertSuccessfulPostEdit("Test Post Edit"); }
public void EditForeignPost() { HomePage homePage = new HomePage(this.driver); homePage.NavigateTo(); LoginPage logPage = new LoginPage(this.driver); logPage.NavigateTo(); var loginUser = AccessExcelData.GetTestDataLoging("LoginForeinUserData"); logPage.FillLoginForm(loginUser); homePage.EditPostLink.Click(); EditPost editPage = new EditPost(this.driver); editPage.NavigateTo(); editPage.Title.Click(); editPage.EditButton.Click(); editPage.AssertEditForeignPostErrorMessageIsDisplayed("You do not have permission to view this directory or page"); }
public void OnGet(int?id) { _id = id; Post = _postsService.GetEditPost(id); }
public void Put(int id, [FromBody] Post value) { IEditPost updateObject = new EditPost(); updateObject.EditAPost(value); }
public ActionResultStatus EditPostWithoutPhoto(EditPost editPost) { return(postService.EditPostWithoutPhoto(editPost)); }