예제 #1
0
        /// <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;
        }
예제 #2
0
        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));
        }
예제 #3
0
 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);
     }
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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());
        }
예제 #6
0
 public Task <int> UpdateClusterNodeAsync(ClusterNode entity)
 {
     serviceDbContext.Entry(entity).State = EntityState.Modified;
     return(serviceDbContext.SaveChangesAsync());
 }
예제 #7
0
 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);
 }
예제 #8
0
 public Task <int> UpdateAsync(SshKey sshKey)
 {
     serviceDbContext.Entry(sshKey).State = EntityState.Modified;
     return(serviceDbContext.SaveChangesAsync());
 }
예제 #9
0
 public Task <int> UpdateAsync(TraefikRouteValue entity)
 {
     serviceDbContext.Entry(entity).State = EntityState.Modified;
     return(serviceDbContext.SaveChangesAsync());
 }