Exemplo n.º 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 });
 }
Exemplo n.º 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 });
 }
Exemplo n.º 3
0
 partial void DeleteRelation(Relation instance);
Exemplo n.º 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);
 }
Exemplo n.º 5
0
 partial void InsertRelation(Relation instance);
Exemplo n.º 6
0
 partial void UpdateRelation(Relation instance);
Exemplo n.º 7
0
		private void detach_Relations(Relation entity)
		{
			this.SendPropertyChanging();
			entity.Role = null;
		}
Exemplo n.º 8
0
		private void attach_Relations(Relation entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}
Exemplo n.º 9
0
 public void Delete(Relation relation)
 {
     _db.Relations.DeleteOnSubmit(relation);
 }
Exemplo n.º 10
0
 public void Add(Relation relation)
 {
     _db.Relations.InsertOnSubmit(relation);
 }
Exemplo n.º 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);
 }