public void AssignTags(string tags, IEnumerable<Tag> tagsList, Conference conference)
 {
     conference.Tags = new List<Tag>();
     var stringTags = tags.Split(',');
     var intTag = stringTags.Select(e => int.Parse(e)).ToList();
     tagsList.Where(e => intTag.Contains(e.TagID)).ToList()
         .ForEach(e => e.Conferences.Add(conference));
     tagsList.ToList().ForEach(e => _repository.UpdateAndSubmit(e));
 }
 public void AssignImage(HttpPostedFileBase image, Conference conference)
 {
     var img = new Image
     {
         ImageData = image.InputStream.ToByteArray(),
         ImageMimeType = image.ContentType
     };
     conference.Image = img;
 }
        public void AssignOrganizer(string userId, Conference conference)
        {
            var attendee = _repository.GetById<Attendee>(null, userId);
            var organizer = attendee.Organizer ?? new Organizer
            {
                User = attendee
            };

            conference.Organizer = organizer;
        }
 public void AssignSpeakers(string speakers, IEnumerable<Speaker> speakersDb, Conference conference)
 {
     conference.Tags = new List<Tag>();
     var stringSpeakers = speakers.Split(',').ToList();
     var attendees = AllUsers.Where(e => stringSpeakers.Any(l => l == e.Id));
     foreach (var attendee in attendees)
     {
         var speaker = new Speaker() {User = attendee};
         speakersDb.ToList().Add(speaker);
     }
 }
 public void EditConferenceProperties(Conference conference, Conference confToEdit, City city, Country country)
 {
     confToEdit.Name = conference.Name;
     confToEdit.StartDate = conference.StartDate;
     confToEdit.EndDate = conference.EndDate;
     confToEdit.Url = conference.Url;
     confToEdit.IsPaid = confToEdit.IsPaid;
     confToEdit.TargetCityId = conference.TargetCityId;
     confToEdit.TargetCity = city;
     confToEdit.TargetCountryId = conference.TargetCountryId;
     confToEdit.TargetCountry = country;
 }
        public ActionResult Create(string tags, Conference conference, HttpPostedFileBase image, string userId)
        {
            ViewData["TagsSelector"] = new MultiSelectList(Tags, "TagID", "Name");
            ViewData["TargetCountryId"] = new SelectList(Countries, "CountryID", "Name");

            try
            {
                if (image != null)
                    _controllerHelper.AssignImage(image, conference);

                if (!string.IsNullOrWhiteSpace(userId))
                    _controllerHelper.AssignOrganizer(userId, conference);

                _repository.InsertAndSubmit(conference);

                if (tags != "null")
                    _controllerHelper.AssignTags(tags, Tags, conference);

                Success("Great job, You added the event!", true);
                return View(conference);
            }
            catch (Exception dbEx)
            {
                Danger("Unable to save changes. Try again, and if the problem persists see your system administrator.",
                    true);
                return View();
            }
        }