Beispiel #1
0
 public ActionResult EditRelation(Relation vm)
 {
     if (Repository.Relations.Any(r => r.PersonId == vm.PersonId && r.BookId == vm.BookId && r.Id != vm.Id)) ModelState.AddModelError("PersonId", Phrases.ValidationPersonHasRelationToBook);
     if (!ModelState.IsValid)
     {
         ViewBag.People = PeopleList(vm.PersonId);
         ViewBag.Roles = RoleList(vm.RoleId);
         vm.Book = Repository.GetBook(vm.BookId);
         return View(vm);
     }
     UpdateModel(Repository.GetRelation(vm.Id));
     Repository.Save();
     return RedirectToAction("updaterelationcache", new { id = vm.BookId });
 }
Beispiel #2
0
 public ActionResult RemoveRelation(Relation vm)
 {
     var relation = Repository.GetRelation(vm.Id);
     Repository.Delete(relation);
     Repository.Save();
     return RedirectToAction("updaterelationcache", new { id = relation.BookId });
 }
 partial void DeleteRelation(Relation instance);
Beispiel #4
0
 public ActionResult CreateRelation(int id)
 {
     var book = Repository.GetBook(id);
     if (book == null) return HttpNotFound();
     var vm = new Relation
         {
             BookId = id,
             Book = book,
             SequenceIdentifier = int.MaxValue
         };
     ViewBag.People = PeopleList(vm.PersonId);
     ViewBag.Roles = RoleList(vm.RoleId);
     return View(vm);
 }
 partial void InsertRelation(Relation instance);
 partial void UpdateRelation(Relation instance);
		private void detach_Relations(Relation entity)
		{
			this.SendPropertyChanging();
			entity.Role = null;
		}
		private void attach_Relations(Relation entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}
Beispiel #9
0
 public void Delete(Relation relation)
 {
     _db.Relations.DeleteOnSubmit(relation);
 }
Beispiel #10
0
 public void Add(Relation relation)
 {
     _db.Relations.InsertOnSubmit(relation);
 }
Beispiel #11
0
 public static HtmlString RelationLinkOrName(this HtmlHelper helper, Relation relation)
 {
     return relation.Person.HasPage
         ? helper.ActionLink(relation.ReversePersonName, "details", "authors", new { id = relation.PersonId }, null)
         : new HtmlString(relation.ReversePersonName);
 }