예제 #1
0
        public string saveClub(string name, Stadium stadium, City city, User user)
        {
            var message = "";
            var result  = new Organization();
            var result2 = new OrgStadium();

            if (!String.IsNullOrEmpty(name))
            {
                result.Name = name;
                result.City = city;
                result.User = user;

                result2.Organization = result;
                result2.Stadium      = stadium;

                _clubRepository.AddClub(result, result2);
                message = "Podaci su uspješno spremljeni";
            }
            else
            {
                message = "Ime kluba nije uneseno";
            }

            return(message);
        }
예제 #2
0
        public void UpdateClub(Organization org, OrgStadium stadium)
        {
            var clas = new Class1();

            using (var session = clas.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.SaveOrUpdate(org);
                    session.SaveOrUpdate(stadium);
                    transaction.Commit();
                }
            }
        }
        public Stadium GetOrganizationStadium(int organizationId)
        {
            var result = new OrgStadium();
            var clas   = new Class1();

            using (var session = clas.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    result = (OrgStadium)session.QueryOver <OrgStadium>().Where(org => org.Organization.Id == organizationId).List().FirstOrDefault();
                    transaction.Commit();
                }
            }
            return(result.Stadium);
        }
예제 #4
0
        public OrgStadium GetOrgStadForClub(int id)
        {
            OrgStadium message = null;
            var        clas    = new Class1();

            using (var session = clas.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var result = (OrgStadium)session.QueryOver <OrgStadium>().JoinQueryOver(x => x.Organization).Where(u => u.Id == id).List().FirstOrDefault();
                    // var result = (OrgStadium)session.QueryOver<OrgStadium>().Where(u => u.Organization == club).List().FirstOrDefault();
                    if (result != null)
                    {
                        message = result;
                    }
                    transaction.Commit();
                }
            }
            return(message);
        }