public static void TrackChange(ClanciIzmjene articleChange) { Connection.dm.ClanciIzmjene.Add(articleChange); Connection.dm.SaveChanges(); }
protected void saveArticleSubmit_Click(object sender, EventArgs e) { try { if (documentFile.PostedFile.ContentLength == 0) article = DAClanci.Select(articleId); else if (documentFile.PostedFile != null && documentFile.PostedFile.FileName != null && documentFile.PostedFile.FileName != "") { string extension = ""; article = new Clanci(); article.ClanakID = articleId; extension = System.IO.Path.GetExtension(documentFile.PostedFile.FileName); if (extension == ".pdf") { article.DokumentType = documentFile.PostedFile.ContentType; article.Dokument = new byte[documentFile.PostedFile.ContentLength]; documentFile.PostedFile.InputStream.Read(article.Dokument, 0, documentFile.PostedFile.ContentLength); string filename = article.ClanakID + extension; System.IO.File.WriteAllBytes(Server.MapPath("/Content/articles/") + filename, article.Dokument); article.DokumentPath = "~/Content/articles/" + filename; } else { errorLabel.Text = "Podržani format dokumenta je pdf."; error_label.Visible = true; return; } } if (typesList.SelectedIndex != 0) article.VrstaID = Convert.ToInt32(typesList.SelectedValue); if (themeList.SelectedIndex != 0) article.TemaID = Convert.ToInt32(themeList.SelectedValue); article.Naslov = titleInput.Text.Trim(); article.Autori = authorsInput.Text.Trim(); article.KljucneRijeci = keyWordsInput.Text.Trim(); article.DatumKreiranja = DateTime.Now; article.DatumIzmjene = DateTime.Now; article.Status = true; article.KorisnikID = Convert.ToInt32(User.Identity.Name); article.Tekst = wysiwyg.InnerText; List<string> tags = new List<string>(); foreach (string tag in tagsInput.Text.Split(',')) { if (tag.Trim() != "") tags.Add(tag.Trim()); } DAClanci.Update(article, tags); //Praćenje izmjena članka ClanciIzmjene articleChange = new ClanciIzmjene(); articleChange.KorisnikID = Convert.ToInt32(User.Identity.Name); articleChange.ClanakID = articleId; articleChange.Datum = DateTime.Now; articleChange.Opis = editDescriptionInput.InnerText; DAClanci.TrackChange(articleChange); successLabel.Text = "Uspješno ste sačuvali izmjene."; error_label.Visible = false; success_label.Visible = true; } catch (Exception ex) { errorLabel.Text = ex.Message; if (ex.InnerException != null) errorLabel.Text += "\n" + ex.InnerException; error_label.Visible = true; } }