Esempio n. 1
0
        public static T ToABPageTestResultEntity <T>(this ABPageTestResult model, T entity)
            where T : IABPageTestResultEntity
        {
            entity.UUID = model.UUID;
            if (null != model.Site)
            {
                entity.SiteName = model.Site.FullName;
            }

            entity.ObjectXml = DataContractSerializationHelper.SerializeAsXml(model, KnownTypes);
            return(entity);
        }
Esempio n. 2
0
        private void UpdateOrAdd(ABPageTestResult item, ABPageTestResult oldItem)
        {
            ((IPersistable)item).OnSaving();
            var dummy = _dbContext.ABPageTestResults.FirstOrDefault(it => it.UUID.Equals(oldItem.UUID, StringComparison.OrdinalIgnoreCase) &&
                                                                    it.SiteName.Equals(oldItem.Site.FullName, StringComparison.OrdinalIgnoreCase));

            if (null != dummy)
            {
                item.ToABPageTestResultEntity <ABPageTestResultEntity>(dummy);
            }
            else
            {
                dummy = item.ToABPageTestResultEntity <ABPageTestResultEntity>();
                _dbContext.ABPageTestResults.Add(dummy);
            }
            _dbContext.SaveChanges();
            ((IPersistable)item).OnSaved();
        }
Esempio n. 3
0
        public static ABPageTestResult ToABPageTestResult(this IABPageTestResultEntity entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dummy = new ABPageTestResult();

            dummy.UUID = entity.UUID;
            dummy.Site = new Site(entity.SiteName);

            var result = DataContractSerializationHelper.DeserializeFromXml <ABPageTestResult>(entity.ObjectXml, KnownTypes);

            ((IPersistable)result).Init(dummy);

            return(result);
        }
Esempio n. 4
0
 public static T ToABPageTestResultEntity <T>(this ABPageTestResult model)
     where T : IABPageTestResultEntity, new()
 {
     return(ToABPageTestResultEntity(model, new T()));
 }