Пример #1
0
 public Measurement(TankMeasurement unit,
                    int top, int bottom, int quantity)
 {
     Unit        = unit;
     Top         = top;
     Bottom      = bottom;
     Quantity    = quantity;
     NetQuantity = top + bottom + quantity;
 }
Пример #2
0
 public TankMeasurement UpdateTankMeasurement(TankMeasurement tankMeasurement)
 {
     try
     {
         var result = _context.TankMeasurements.Update(tankMeasurement);
         _context.SaveChanges();
         return(result.Entity);
     }
     catch (Exception ex)
     {
         _logger.LogError(Utility.FlattException(ex));
         return(null);
     }
 }
        public TankMeasurement UpdateTankMeasurement(TankMeasurement tankMeasurement)
        {
            try
            {
                var currentValue = _context.TankMeasurements.First(n => n.TankMeasurementId == tankMeasurement.TankMeasurementId);
                tankMeasurement.CreatedBy               = currentValue.CreatedBy;
                tankMeasurement.DatetimeCreated         = currentValue.DatetimeCreated;
                tankMeasurement.DatetimeUpdated         = DateTime.Now;
                tankMeasurement.UpdatedBy               = "SYSTEM";
                tankMeasurement.TankMeasurementDatetime = currentValue.TankMeasurementDatetime;
                _context.Entry(currentValue).State      = Microsoft.EntityFrameworkCore.EntityState.Detached;
                _context.Entry(tankMeasurement).State   = Microsoft.EntityFrameworkCore.EntityState.Modified;
                var updateResult = _context.TankMeasurements.Update(tankMeasurement);


                _context.SaveChanges();
                return(updateResult.Entity);
            }
            catch (Exception ex)
            {
                _logger.LogError(Utility.FlattException(ex));
                return(null);
            }
        }
Пример #4
0
 public Measurement ChangeUnit(TankMeasurement unit)
 {
     return(new Measurement(unit, this.Top, this.Bottom, this.Quantity));
 }