Example #1
0
        //Ask DAL to Add club
        public string AddClub(ClubDTO club)
        {
            //Get list of current existing clubs
            Clubs = GetClubs();

            //Check if there's any club with given name
            foreach (ClubDTO item in Clubs)
            {
                if (item.Name == club.Name)
                {
                    message.Append("There's already an existing club with that name.");
                    return(message.ToString());
                }
            }

            //If club doesn't exist yet, set default value to photo if not added.
            Club c = Mapper.Map <Club>(club);

            if (c.Photo is null || c.Photo == "")
            {
                c.Photo = "No photo";
            }

            if (Repository.AddClub(c))
            {
                message.Append("Club has been created!");
            }
            else
            {
                message.Append("Something went wrong.");
            }
            return(message.ToString());
        }