protected void Edit_Click(object sender, EventArgs e) { if (FileUploadAuthorPicture.HasFile) { string fileName = FileUploadAuthorPicture.FileName; string folderPath = Server.MapPath("/Files/Images/"); string image = "/Files/Images/" + fileName; string storeImage = folderPath + fileName; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } FileUploadAuthorPicture.SaveAs(storeImage); lblFileUploadAuthorPicture.Text = "Image upload successfully"; lblFileUploadAuthorPicturePath.Text = Request.UrlReferrer + image; lblFileUploadAuthorPicture.ForeColor = System.Drawing.Color.Green; } else { lblFileUploadAuthorPicture.ForeColor = System.Drawing.Color.Red; lblFileUploadAuthorPicture.Text = "Please select Image"; } Uri myUri = new Uri(Request.Url.ToString()); string AuthorID = HttpUtility.ParseQueryString(myUri.Query).Get("ID"); AuthorController ac = new AuthorController(); ac.Update(int.Parse(AuthorID), txtAuthorName.Text, txtAuthorJobTitle.Text, txtAuthorAddress.Text, txtAuthorEmail.Text, txtAuthorWebsite.Text, lblFileUploadAuthorPicturePath.Text, txtAuthorLinkedIn.Text, txtAuthorFacebook.Text, txtAuthorTwitter.Text, txtAuthorInstagram.Text, int.Parse(ddlLanguageId.SelectedValue)); Response.Redirect("ListAuthor.aspx"); }
public void Update_ShouldUpdateItem() { string updatedFirstName = "Джек"; string updatedLastName = "Лондон"; var updatedAuthor = new AuthorItem { Id = _JackLondonId, FirstName = updatedFirstName, LastName = updatedLastName }; var result = _controller.Update(_JackLondonId, updatedAuthor); Assert.IsType <NoContentResult>(result); var author = _context.Authors.FirstOrDefault(c => c.Id == _JackLondonId); Assert.Equal(updatedFirstName, author.FirstName); Assert.Equal(updatedLastName, author.LastName); }
public void TestUpdate(AuthorViewModel model, string name, string test, string result) { _init(); AuthorController controler = new AuthorController(_service); controler.New(model).GetAwaiter().GetResult(); var r = controler.Vizualise(1) as PartialViewResult; var _model = (r.Model as AuthorViewModel); _model.Name = name; controler.Update(_model).GetAwaiter().GetResult(); r = controler.Vizualise(1) as PartialViewResult; _model = (r.Model as AuthorViewModel); Assert.IsTrue(_model.Name == result, $"Erro no Teste: {test}"); }