Пример #1
0
 public static void ToEntity(DT.Statistics source, Statistics target)
 {
     if ((source != null) && (target != null))
     {
         target.StatisticsId = source.Id;
         target.Timestamp    = source.TimeStamp;
     }
 }
Пример #2
0
        public static Statistics ToEntity(DT.Statistics source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new Statistics(); ToEntity(source, entity);

            return(entity);
        }
Пример #3
0
 public Guid AddStatistics(DT.Statistics dto)
 {
     using (var db = CreateContext()) {
         var entity = Convert.ToEntity(dto);
         db.Statistics.InsertOnSubmit(entity);
         db.SubmitChanges();
         foreach (var slaveStat in dto.SlaveStatistics)
         {
             slaveStat.Id = entity.StatisticsId;
             db.SlaveStatistics.InsertOnSubmit(Convert.ToEntity(slaveStat));
         }
         foreach (var userStat in dto.UserStatistics)
         {
             userStat.Id = entity.StatisticsId;
             db.UserStatistics.InsertOnSubmit(Convert.ToEntity(userStat));
         }
         db.SubmitChanges();
         return(entity.StatisticsId);
     }
 }