コード例 #1
0
        public int Update(MappingSyncModel mapping)
        {
            var mappingRepo = new MappingRepository(DatabaseFactory);
            var item        = DataContext.Mappings.FirstOrDefault(f => f.TypeId == mapping.TypeId && f.MappingType.Id == mapping.MappingTypeId);

            if (item != null)
            {
                item.LastModifiedDate = DateTime.Now;
                item.TypeName         = mapping.TypeName;
                item.IsActive         = mapping.IsActive;
            }
            return(DataContext.SaveChanges());
        }
コード例 #2
0
        public int Add(MappingSyncModel mapping)
        {
            var mappingRepo     = new MappingRepository(DatabaseFactory);
            var mappintTypeRepo = new MappingTypeRepository(DatabaseFactory);
            var item            = new Mapping
            {
                CreationDate = DateTime.Now,
                IsActive     = mapping.IsActive,
                MappingType  = mappintTypeRepo.GetMany(x => x.Id == mapping.MappingTypeId).FirstOrDefault(),
                TypeId       = mapping.TypeId,
                TypeName     = mapping.TypeName
            };

            DataContext.Mappings.Add(item);
            return(DataContext.SaveChanges());
        }