public IActionResult Create(Footer model) { if (ModelState.IsValid) { Footer entity = new Footer() { SocialMediaName = model.SocialMediaName, Link = model.Link, Icon = model.Icon //combobox? }; repository.Add(entity); repository.Save(); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Add(int id, string content) { try { if (id == 0) { footerRepository.Add(content); } else { Footer footer = new Footer(); footer.ID = id; footer.Contents = content; footerRepository.Edit(footer); } return(Json(new { IsSuccess = true, Message = "Lưu thành công" }, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(new { IsSuccess = false, Message = "Lưu thất bại" }, JsonRequestBehavior.AllowGet)); } }
public Footer Add(Footer Footer) { return(_footerRepository.Add(Footer)); }
public void Add(Footer footer) { _footerRepository.Add(footer); }
public async Task <Footer> Add(Footer footer) { return(await Task.FromResult(_footerRepository.Add(footer))); }
public void TestFooterIsUpdatedCorrectlyFromDatabase() { User user = new User { UserName = "******", Password = "******", Name = "name", LastName = "lastname", Email = Guid.NewGuid().ToString(), Administrator = true }; UserRepository.Add(user); StyleClass StyleClassF1 = new StyleClass { Name = "StyleClassF1", BasedOn = null }; StyleClassRepository.Add(StyleClassF1); Document document = new Document { Id = Guid.NewGuid(), Title = "title1", Creator = user, CreationDate = DateTime.Now, LastModification = DateTime.Now, StyleClass = StyleClassF1 }; DocumentRepository.Add(document); Content content = new Content { Id = Guid.NewGuid(), }; ContentRepository.Add(content); Footer footer = new Footer { Id = Guid.NewGuid(), Content = content, DocumentThatBelongs = document, StyleClass = StyleClassF1 }; FooterRepository.Add(footer); Footer updatedFooter = new Footer { Id = footer.Id, Content = content, DocumentThatBelongs = document, StyleClass = null }; FooterRepository.Update(updatedFooter); Footer fromDatabase = FooterRepository.GetById(updatedFooter.Id); StyleClassRepository.Delete(StyleClassF1.Name); DocumentRepository.Delete(document.Id); UserRepository.Delete(user.Email); ContentRepository.Delete(content); Assert.AreEqual(updatedFooter.Id, fromDatabase.Id); Assert.AreEqual(updatedFooter.Content.Id, fromDatabase.Content.Id); Assert.IsNull(updatedFooter.StyleClass); Assert.AreEqual(updatedFooter.DocumentThatBelongs.Id, fromDatabase.DocumentThatBelongs.Id); }
public void TestDocumentDeleteWithOneHeaderOneFooterOneParagraphFromDatabase() { User user4 = new User { UserName = "******", Password = "******", Name = "name4", LastName = "lastname3", Email = "email3", Administrator = true }; UserRepository.Add(user4); Document document = new Document { Id = Guid.NewGuid(), Title = "title", Creator = user4, CreationDate = DateTime.Now, LastModification = DateTime.Now, StyleClass = null }; DocumentRepository.Add(document); Header header = new Header { Id = Guid.NewGuid(), Content = null, DocumentThatBelongs = document, StyleClass = null }; HeaderRepository.Add(header); Footer footer = new Footer { Id = Guid.NewGuid(), Content = null, DocumentThatBelongs = document, StyleClass = null }; FooterRepository.Add(footer); Paragraph paragraph1 = new Paragraph { Id = Guid.NewGuid(), Content = null, DocumentThatBelongs = document, StyleClass = null, Position = 0 }; ParagraphRepository.Add(paragraph1); Paragraph paragraph2 = new Paragraph { Id = Guid.NewGuid(), Content = null, DocumentThatBelongs = document, StyleClass = null, Position = 1 }; ParagraphRepository.Add(paragraph2); DocumentRepository.Delete(document.Id); UserRepository.Delete(user4.Email); bool headerExistsAfterDelete = HeaderRepository.Exists(header.Id); bool paragraph1ExistsAfterDelete = ParagraphRepository.Exists(paragraph1.Id); bool paragraph2ExistsAfterDelete = ParagraphRepository.Exists(paragraph2.Id); bool footerExistsAfterDelete = FooterRepository.Exists(footer.Id); Assert.IsFalse(headerExistsAfterDelete); Assert.IsFalse(paragraph1ExistsAfterDelete); Assert.IsFalse(paragraph2ExistsAfterDelete); Assert.IsFalse(footerExistsAfterDelete); }
public void Add(Footer Footer) { sizeRepository.Add(Footer); }