Ejemplo n.º 1
0
 public void ShouldMapFromTranslationToGateway()
 {
     crds_angular.Models.Crossroads.Events.Event gatewayEvent =
         AutoMapper.Mapper.Map <MpEvent, crds_angular.Models.Crossroads.Events.Event>(
             EventHelpers.TranslationEvent()
             );
     Assert.AreEqual(gatewayEvent.name, EventHelpers.GatewayEvent().name);
     Assert.AreEqual(gatewayEvent.location, EventHelpers.GatewayEvent().location);
     Assert.AreEqual(gatewayEvent.StartDate, EventHelpers.GatewayEvent().StartDate);
     Assert.AreEqual(gatewayEvent.EndDate, EventHelpers.GatewayEvent().EndDate);
     Assert.AreEqual(gatewayEvent.EventId, EventHelpers.GatewayEvent().EventId);
 }
Ejemplo n.º 2
0
        private List<Event> ConvertToEvents(List<Dictionary<string, object>> todaysEvents)
        {
            //init our return variable
            var events = new List<Event>();

            //iterate over the events
            foreach (var thisEvent in todaysEvents)
            {
                string startDateKey = "Event_Start_Date";
                string nameKey = "Event_Title";
                string locationNameKey = "Room_Name";
                string locationNumberKey = "Room_Number";
                string time = "";
                string meridian = "";
                string name = "";
                string location = "";
                if (thisEvent.ContainsKey(startDateKey) && thisEvent[startDateKey] != null)
                {
                    DateTime startDate = (DateTime)thisEvent[startDateKey];
                    time = startDate.ToString("h:mm");
                    meridian = startDate.ToString("tt");
                }
                if (thisEvent.ContainsKey(nameKey) && thisEvent[nameKey] != null)
                {
                    name = thisEvent[nameKey].ToString();
                }
                if (thisEvent.ContainsKey(locationNameKey) && thisEvent[locationNameKey] != null)
                {
                    location = thisEvent[locationNameKey].ToString();
                }
                if (thisEvent.ContainsKey(locationNumberKey) && thisEvent[locationNumberKey] != null)
                {
                    location += " " + thisEvent[locationNumberKey].ToString();
                }
                var e = new Event
                {
                    time = time,
                    meridian = meridian,
                    name = name,
                    location = location
                };
                events.Add(e);
            }
            return events;
        }