Пример #1
0
        private Query GetAddEventResultQuery(EventResultDto eventResultDto)
        {
            const string userTemplate = "Northernrunners.ImportLibrary.Resources.CreateEventResultTemplate.txt";

            var queries = new List<Query>();
            Query query;
            using (var stream = _assembly.GetManifestResourceStream(userTemplate))
            {
                var sql = Tools.StreamToString(stream);
                query = new Query { Sql = sql };
            }
            var properties = typeof(EventResultDto).GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();
            var sqlParams = GetParams(query.Sql);

            if (properties.Count != sqlParams.Count)
            {
                throw new Exception("Invalid properties");
            }

            var sqlParameters = query.ParameterValues;
            foreach (var property in properties)
            {
                if (!sqlParams.Contains(property.Name))
                {
                    throw new Exception("Cannot find property: " + property.Name);
                }
                sqlParameters.Add(new Parameter("@" + property.Name, property.GetValue(eventResultDto)));
            }
            return query;
        }
Пример #2
0
        public void AddEventResults(EventResultDto eventResultDto)
        {
            var query = GetAddEventResultQuery(eventResultDto);

            _sqlDirectService.RunCommand(query);



        }
Пример #3
0
        public void Serializer()
        {
            var input = new EventResultDto {AgeGrade = 3};
            var xml = Tools.Serialize(input);
            Console.WriteLine(xml);
            input = Tools.Deserializate<EventResultDto>(xml);
            Console.WriteLine(input.AgeCategory);
            

        }
Пример #4
0
        private static EventResultDto GetEventResult()
        {
            //var eventResult = new EventResult();

            var eventResultDto = new EventResultDto
            {
                AgeCategory = "A40",
                AgeGrade = 63.12,
                DateCreated = DateTime.Now,
                EventId = 2,
                Position = 23,
                Gender = "F",
                Time = 2900000,
                UserId = 3
            };

            return eventResultDto;

        }
Пример #5
0
 public void AddEventResults(EventResultDto eventResult)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 private EventResultDto CreateEventResultDto(Event ev, Result result, int time)
 {
     var eventResultDto = new EventResultDto
     {
         EventId = ev.Id,
         AgeCategory = GetAgeCategory(result.User, ev),
         AgeGrade = GetAgeGrade(result.User, result.Time, ev),
         DateCreated = DateTime.Now,
         Gender = result.User.Gender,
         UserId = result.User.Id,
         Time = time,
         Position = result.Position
     };
     return eventResultDto;
 }