public ViewResult Edit(UserGroup userGroup, Sponsor sponsor) { if (!_securityContext.IsAdmin()) { return NotAuthorizedView; } if (sponsor != null) { sponsor.UserGroup=userGroup; } return AutoMappedView<UpdateSponsorInput>(sponsor??new Sponsor(){UserGroup=userGroup}); }
public void Should_map_a_sponsor() { var userGroup = new UserGroup(); var sponsor = new Sponsor { Name = "FooBar", Level =SponsorLevel.Gold, Url = "http://thisistheurl.com/", UserGroup = userGroup }; PersistEntities(userGroup); AssertObjectCanBePersisted(sponsor); }
public void should_create_audit_info_on_save_and_update_child_entities() { ResetCurrentUser(); User user1 = CurrentUser; user1.Username = "******"; PersistEntities(user1); var group = new UserGroup(); var sponsor = new Sponsor(); group.Add(sponsor); PersistEntitiesWithAuditing(user1, new DateTime(2009, 4, 5), group, sponsor); var group1 = GetAuditedSession(user1, new DateTime(2009, 4, 5)).Load<UserGroup>(group.Id); group1.ChangeAuditInfo.Created.ShouldEqual(new DateTime(2009, 4, 5)); group1.ChangeAuditInfo.CreatedBy.ShouldEqual(user1.Username); group1.ChangeAuditInfo.Updated.ShouldEqual(new DateTime(2009, 4, 5)); group1.ChangeAuditInfo.UpdatedBy.ShouldEqual(user1.Username); Sponsor sponsor1 = group.GetSponsors()[0]; sponsor1.ChangeAuditInfo.Created.ShouldEqual(new DateTime(2009, 4, 5)); sponsor1.ChangeAuditInfo.CreatedBy.ShouldEqual(user1.Username); sponsor1.ChangeAuditInfo.Updated.ShouldEqual(new DateTime(2009, 4, 5)); sponsor1.ChangeAuditInfo.UpdatedBy.ShouldEqual(user1.Username); }
public virtual void Remove(Sponsor child) { _sponsors.Remove(child); }
public virtual void Add(Sponsor child) { _sponsors.Add(child); }
public ActionResult Delete(UserGroup userGroup, Sponsor sponsor) { userGroup.Remove(sponsor); _repository.Save(userGroup); return RedirectToAction<SponsorController>(c => c.Index(null)); }