Ejemplo n.º 1
0
 public bool Update(Pulse entity)
 {
     using (logger.BeginScope(nameof(this.Update)))
     {
         if (entity == null)
         {
             logger.LogWarning("ArgumentNullException while updating pulse in DB");
             return false;
         }
         using (var context = new PsqlContext())
         {
             try
             {
                 DbPulse dbPulse = entity.ToDbEntity();
                 context.Pulse.Update(dbPulse);
                 context.SaveChanges();
                 logger.LogDebug("Pulse updated successfully");
                 return true;
             }
             catch (Exception e)
             {
                 logger.LogWarning(e.ToString() + " while updating pulse in DB");
                 return false;
             }
         }
     }
 }
Ejemplo n.º 2
0
        internal static Pulse ToDomainEntity(this DbPulse entity)
        {
            Pulse pulse = new Pulse
            {
                SessionID = entity.SessionId,
                BPM       = entity.Bpm,
                TimeStamp = DateTime.SpecifyKind(entity.timestamp, DateTimeKind.Utc)
            };

            return(pulse);
        }
Ejemplo n.º 3
0
        internal static DbPulse ToDbEntity(this Pulse entity)
        {
            DbPulse pulse = new DbPulse
            {
                SessionId = entity.SessionID,
                Bpm       = entity.BPM,
                timestamp = entity.TimeStamp
            };

            return(pulse);
        }