/// <summary> /// Find a location from its name and schedule it for deleting on the DB context. /// </summary> public void AttachDeleteLocation(ServiceDbContext context, string name) { var toDelete = new Location { Name = name }; context.Entry(toDelete).State = EntityState.Deleted; }
public Employee EditEmployee(Employee employee) { var originalEmployee = _context.Employees.SingleOrDefault(i => i.Id == employee.Id); if (originalEmployee != null) { _context.Entry(originalEmployee).CurrentValues.SetValues(employee); _context.SaveChanges(); } return(_context.Employees.SingleOrDefault(i => i.Id == originalEmployee.Id)); }
public void UpdateRegion(Region regions) { try { ServiceContext.Entry(regions).State = System.Data.Entity.EntityState.Modified; ServiceContext.SaveChanges(); } catch (Exception ex) { OnAction(DebugLevel.Error, ex.Message, ex.Source, ex.StackTrace, DateTime.Now); } }
public void UpdateDeal(Deal deals) { try { ServiceContext.Entry(deals).State = EntityState.Modified; ServiceContext.SaveChanges(); OnAction(DebugLevel.Information, string.Format("updating {0}", deals.GetType()), "", "", DateTime.Now); } catch (Exception ex) { OnAction(DebugLevel.Error, ex.Message, ex.Source, ex.StackTrace, DateTime.Now); } }
public async Task <IActionResult> PutAd(int id, Ad ad) { // Telemetry _tProperties["Action"] = "PutAd"; if (id != ad.ID) { return(BadRequest("Ids nao conferem")); } _context.Entry(ad).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { if (!AdExists(id)) { return(NotFound()); } else { _telemetry.TrackException(ex, _tProperties); return(BadRequest(ex)); } } catch (Exception ex) { _telemetry.TrackException(ex, _tProperties); return(BadRequest(ex)); } return(NoContent()); }
public Task <int> UpdateClusterNodeAsync(ClusterNode entity) { serviceDbContext.Entry(entity).State = EntityState.Modified; return(serviceDbContext.SaveChangesAsync()); }
public void UpdateFlat(Flat flats) { ServiceContext.Entry(flats).State = System.Data.Entity.EntityState.Modified; ServiceContext.SaveChanges(); OnAction(DebugLevel.Information, string.Format("delas updated"), "", "", DateTime.Now); }
public Task <int> UpdateAsync(SshKey sshKey) { serviceDbContext.Entry(sshKey).State = EntityState.Modified; return(serviceDbContext.SaveChangesAsync()); }
public Task <int> UpdateAsync(TraefikRouteValue entity) { serviceDbContext.Entry(entity).State = EntityState.Modified; return(serviceDbContext.SaveChangesAsync()); }