예제 #1
0
        public AddClubViewModel GetClubById(int id)
        {
            Club club = _clubRepository.GetById(id);
            
            if (club == null)
                return null;

            AddClubViewModel model = new AddClubViewModel()
            {
                Id = club.Id,
                Name = club.Name,
                Logo = club.Logo,
                Status = club.Status,
                ClubAdminName = club.ClubAdmin.User.UserDetail.FirstName,
                ClubAdminEmail = club.ClubAdmin.User.UserName,
                ClubAdminPassword = club.ClubAdmin.User.Password,
                Background = club.Background,
                Established = club.Established,
                Telephone = club.Address.Telephone,
                Mobile = club.Address.Mobile,
                Address1 = club.Address.Address1,
                Address2 = club.Address.Address2,
                Address3 = club.Address.Address3,
                TownCity = club.Address.TownCity,
                PostCode = club.Address.PostCode,
                Chairman = club.Chairman.Name,
                ChairmanEmail = club.Chairman.Email,
                ChairmanTelephone = club.Chairman.Telephone,
                ColorTheme = club.ColorTheme
            };
            return model;
        }
예제 #2
0
        public Club AddClub(AddClubViewModel club)
        {

            var tempClub = new Club()
            {
                Name = club.Name,
                Logo = club.Logo,
                ColorTheme = club.ColorTheme,
                Background = club.Background,
                Status = club.Status,
                Established = club.Established,
                CreateAt = DateTime.Now,
                Address = new Address()
                {
                    Telephone = club.Telephone,
                    Mobile = club.Mobile,
                    Address1 = club.Address1,
                    Address2 = club.Address2,
                    Address3 = club.Address3,
                    TownCity = club.TownCity,
                    PostCode = club.PostCode,
                },
                ClubAdmin = new ClubAdmin()
                {
                    User = new User()
                    {
                        UserName = club.ClubAdminEmail,
                        Role = Role.ClubAdmin,
                        Email = club.ClubAdminEmail,
                        Password = club.ClubAdminPassword,
                        CreateAt = DateTime.Now,
                        UpdateAt = DateTime.Now,
                        LoggedAt = DateTime.Now,
                        UserDetail = new UserDetail()
                        {
                            FirstName = club.ClubAdminName,
                        }

                    }
                },
                Chairman = new Chairman()
                {
                    Name = club.Chairman,
                    Email = club.ChairmanEmail,
                    Telephone = club.ChairmanTelephone,
                },
                
            };
            var newClub =_clubRepository.Add(tempClub);
            newClub.ClubAdmin.Club = newClub;
            newClub.ClubAdmin.User.UserDetail.User = newClub.ClubAdmin.User;
            _clubRepository.Update(newClub,newClub.Id);
            return newClub;
        }
예제 #3
0
        public void UpdateClub(AddClubViewModel club, int id)
        {
            if (club.Id > 0)
            {
               
                var entity = _clubRepository.GetById(id);

                entity.Id = id;

                entity.Name = club.Name;
                entity.Logo = club.Logo;
                entity.ColorTheme = club.ColorTheme;
                entity.Background = club.Background;
                entity.Status = club.Status;
                entity.Established = club.Established;
                entity.Address.Telephone = club.Telephone;
                entity.Address.Mobile = club.Mobile;
                entity.Address.Address1 = club.Address1;
                entity.Address.Address2 = club.Address2;
                entity.Address.Address3 = club.Address3;
                entity.Address.TownCity = club.TownCity;
                entity.Address.PostCode = club.PostCode;
                entity.ClubAdmin.User.UserDetail.FirstName = club.ClubAdminName;
                entity.ClubAdmin.User.UserName = club.ClubAdminEmail;
                entity.ClubAdmin.User.Email = club.ClubAdminEmail;
                entity.ClubAdmin.User.Password = club.ClubAdminPassword;
                entity.Chairman.Name = club.Chairman;
                entity.Chairman.Email = club.ChairmanEmail;
                entity.Chairman.Telephone = club.ChairmanTelephone;

                _clubRepository.Update(entity, id);
            }

        }