public void Should_map_from_entity()
        {
            var user = new User("foo");

            var entity = new CallForSpeakers
            {
                Description = "description",
                EventName = "event name",
                FirstDayOfEvent = new DateTime(2001,1,2),
                Id = 123,
                LastDayOfEvent = new DateTime(2001,1,3),
                LastDayToSubmit = new DateTime(2001,1,4),
                LogoUrl = "logo url",
                Slug = "asdasd",
                Organizer = user
            };

            var input = new CallForSpeakersInput(entity);
            input.Description.ShouldEqual(entity.Description);
            input.EventName.ShouldEqual(entity.EventName);
            input.FirstDayOfEvent.ShouldEqual(entity.FirstDayOfEvent);
            input.Id.ShouldEqual(entity.Id);
            input.LastDayOfEvent.ShouldEqual(entity.LastDayOfEvent);
            input.LastDayToSubmit.ShouldEqual(entity.LastDayToSubmit);
            input.LogoUrl.ShouldEqual(entity.LogoUrl);
        }
        public void UpdateFrom(CallForSpeakersInput input)
        {
            LogoUrl = input.LogoUrl;
            Description = input.Description;

            FirstDayOfEvent = input.FirstDayOfEvent;
            LastDayOfEvent = input.LastDayOfEvent;
            LastDayToSubmit = input.LastDayToSubmit;
        }
 void SetSlug(CallForSpeakersInput input)
 {
     var eventKey = (input.EventName ?? string.Empty).ToLower().Replace(' ', '-');
     if (eventKey.Length > 26)
     {
         eventKey = eventKey.Substring(0, 26);
     }
     var dateKey = FirstDayOfEvent == null ? "" : FirstDayOfEvent.Value.ToString("-yyyy-MM-dd");
     Slug = string.Format("{0}{1}", eventKey, dateKey);
 }
 public ActionResult ProcessCreation(CallForSpeakersInput input)
 {
     if (ModelState.IsValid)
     {
         using (var db = new DataContext())
         {
             db.CallsForSpeakers.Add(new CallForSpeakers(input));
             db.SaveChanges();
         }
         return RedirectToAction("Index", "Home");
     }
     return View();
 }
        public void Should_generate_unique_url_key()
        {
            var input = new CallForSpeakersInput
            {
                Description = "description",
                EventName = "event name",
                LastDayToSubmit = new DateTime(2001, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                FirstDayOfEvent = new DateTime(2001, 2, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                LastDayOfEvent = new DateTime(2001, 3, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                LogoUrl = "logo url"
            };

            var call = new CallForSpeakers(input);

            call.Slug.ShouldEqual("event-name-2001-02-01");
        }
        public void Should_truncate_large_key()
        {
            var input = new CallForSpeakersInput
            {
                Description = "description",
                EventName = "1234567890123456789012345678901234567890",
                LastDayToSubmit = new DateTime(2001, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                FirstDayOfEvent = new DateTime(2001, 2, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                LastDayOfEvent = new DateTime(2001, 3, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                LogoUrl = "logo url"
            };

            var call = new CallForSpeakers(input);

            call.Slug.ShouldEqual("12345678901234567890123456-2001-02-01");
            call.Slug.Length.ShouldBeInRange(1, 40);
        }
        public void When_initializing_data_entity_from_user_input()
        {
            var input = new CallForSpeakersInput
            {
                Description = "description",
                EventName = "event name",
                LastDayToSubmit = new DateTime(2001, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc),
                LogoUrl = "logo url"
            };

            var model = new CallForSpeakers(input);

            model.Description.ShouldEqual(input.Description);
            model.EventName.ShouldEqual(input.EventName);
            model.LastDayToSubmitUtc.ShouldEqual(input.LastDayToSubmit);
            model.LogoUrl.ShouldEqual(input.LogoUrl);
        }
 public CallForSpeakers(CallForSpeakersInput input, User user) : this(input)
 {
     Organizer = user;
 }
 public CallForSpeakers(CallForSpeakersInput input)
 {
     EventName = input.EventName;
     UpdateFrom(input);
     SetSlug(input);
 }