//--------------------------------------------------------------------------------------------------- public void Save(Club obj) { using (var transaction = SessionProvider.Instance.GetSession().BeginTransaction()) { SessionProvider.Instance.GetSession().SaveOrUpdate(obj); transaction.Commit(); } }
//--------------------------------------------------------------------------------------------------- public IList<Event> RecentEvents(int id, int number) { Club c = new Club { Id = id }; return SessionProvider.Instance.GetSession().CreateQuery("FROM Event e WHERE e.Club = :club ORDER BY e.Date DESC") .SetEntity("club", c) .SetMaxResults(number) .List<Event>(); }
//--------------------------------------------------------------------------------------------------- private Club FindOrCreateClub(string name) { // Check the short name first var club = s_club_repository.GetByShortName(name); // If that fails try the full name if (club == null) { club = s_club_repository.GetByName(name); } if (club != null) { // A club was found, return it return club; } else { // No club was found, make a new one with the provided name club = new Club { Name = name, ShortName = name }; s_club_repository.Save(club); return club; } }
public ActionResult Create(Club club) { s_repository.Save(club); return new EmptyResult(); }