Ejemplo n.º 1
0
 public void Copy(SportEvent sportEvent)
 {
     EventId    = sportEvent.EventId;
     SportId    = sportEvent.SportId;
     EventName  = sportEvent.EventName;
     EventDate  = sportEvent.EventDate;
     Team1Price = sportEvent.Team1Price;
     DrawPrice  = sportEvent.DrawPrice;
     Team2Price = sportEvent.Team2Price;
 }
Ejemplo n.º 2
0
        public static void Modify(this SportEventsContext contextEvent, SportEvent sportEvent)
        {
            var result = contextEvent.Events.SingleOrDefault(b => b == sportEvent);

            if (result == null)
            {
                return;
            }
            result.Copy(sportEvent);
            contextEvent.SaveChanges();
        }
Ejemplo n.º 3
0
        public static SportEvent ToSportEvent(this string inputString)
        {
            var data       = inputString.Split('\n', StringSplitOptions.RemoveEmptyEntries);
            var sportEvent = new SportEvent();
            var properties = sportEvent.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var command in data)
            {
                var commands = command.Split(new[] { '-', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var property = properties.Single(x => x.Name == commands[0]);
                property.SetValue(sportEvent,
                                  Convert.ChangeType(string.Join(' ', commands.Skip(1)),
                                                     property.PropertyType));
            }
            return(sportEvent);
        }