Пример #1
0
 /// <summary>
 /// Updates a record from the database
 /// </summary>
 /// <param name="race">A Race model to be modified</param>
 public async Task UpdateAsync(Race race)
 {
     try
     {
         var e = _context.Update(race);
         e.State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw;
         // In here we would log the exception and return an error message to the user
     }
 }
Пример #2
0
 /// <summary>
 /// Updates a record from the database
 /// </summary>
 /// <param name="vehicle">A Vehicle model to be modified</param>
 public async Task UpdateAsync(Vehicle vehicle)
 {
     try
     {
         if (string.IsNullOrEmpty(vehicle.VehicleAlias))
         {
             vehicle.VehicleAlias = vehicle.OwnerName + "'s " + vehicle.Make + " " + vehicle.Model;
         }
         var e = _context.Update(vehicle);
         e.State = EntityState.Modified;
         await _context.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         throw;
         // In here we would log the exception and return an error message to the user
     }
 }