コード例 #1
0
        public static AccessLog ToModel(this RSMDB.AccessHistory from, AccessLog existing = null)
        {
            var entity = (existing == null) ? new AccessLog() : existing;

            entity.EntityType = EntityType.AccessLog;
            entity.InternalId = from.Id;
            entity.AccessType = from.Type;
            entity.Reason     = from.Reason != null ? (int)from.Reason : entity.Reason;
            entity.Accessed   = from.Accessed;

            entity.PersonId = from.PersonId;
            if (from.Person != null)
            {
                entity.Person = from.Person.ToModel(entity.Person);
            }

            entity.PortalId = from.PortalId;
            if (from.Portal != null)
            {
                entity.Portal = from.Portal.ToModel(entity.Portal);
            }

            entity.ReaderId = from.ReaderId;
            if (from.Reader != null)
            {
                entity.Reader = from.Reader.ToModel(entity.Reader);
            }

            return(entity);
        }
コード例 #2
0
        public static RSMDB.AccessHistory Insert(this AccessLog entity, RSMDB.RSMDataModelDataContext context)
        {
            var row = new RSMDB.AccessHistory
            {
                PersonId = entity.PersonId,
                PortalId = entity.PortalId,
                ReaderId = entity.ReaderId,
                Reason   = entity.Reason,
                Type     = entity.AccessType,
                Accessed = entity.Accessed,
            };

            context.AccessHistories.InsertOnSubmit(row);

            context.SubmitChanges();

            return(row);
        }