Ejemplo n.º 1
0
        public virtual void Update(TEntity entity, string modifiedBy = null)
        {
            TEntity oldEntity = Context.Set <TEntity>().Find(entity.Id);

            Context.Entry(oldEntity).State = EntityState.Detached;
            //Context.Set<TEntity>().Update(entity);
            Context.Entry(entity).State = EntityState.Modified;
        }
Ejemplo n.º 2
0
        public IActionResult Edit(Staff staff)
        {
            if (ModelState.IsValid)
            {
                db.Entry(staff).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public List <Aircrafts> GetAll()
        {
            var all = dataSource.AircraftsList.ToList();

            foreach (var t in all)
            {
                dataSource.Entry(t).Reference(x => x.AircraftsModels).Load();
            }
            return(all);
        }
Ejemplo n.º 4
0
        public List <Flights> GetAll()
        {
            var t = dataSource.FlightsList.ToList();

            foreach (var t1 in t)
            {
                dataSource.Entry(t1).Collection(x => x.Tickets).Load();
            }
            return(t);
        }
Ejemplo n.º 5
0
        public IActionResult Edit(Flight flight)
        {
            if (ModelState.IsValid)
            {
                db.Entry(flight).State             = EntityState.Modified;
                db.Entry(flight.JobAirplane).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public async Task UpdateAsync(object id, TEntity entity)
        {
            entity.Id = (int)id;
            var existedEntity = await _ctx.Set <TEntity>().FindAsync(id);

            _ctx.Entry(existedEntity).CurrentValues.SetValues(entity);
        }
        public async Task UpdateAsync(object id, Flight entity)
        {
            entity.Number = (string)id;
            var existedEntity = await _ctx.Flights.FindAsync(id);

            _ctx.Entry(existedEntity).CurrentValues.SetValues(entity);
        }
        public async Task <IActionResult> PutFlight([FromRoute] int id, [FromBody] Flight flight)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != flight.FlightId)
            {
                return(BadRequest());
            }

            _context.Entry(flight).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FlightExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                    //var reloadFlight = await _context.Flights.FindAsync(id);
                    //_context.Entry(flight).State = EntityState.Modified;
                    //await _context.SaveChangesAsync();
                }
            }

            return(NoContent());
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> PutBagage(int id, Bagage bagage)
        {
            if (id != bagage.ID_BAGAGE)
            {
                return(BadRequest());
            }

            _context.Entry(bagage).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BagageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> PutVol(int id, Vol vol)
        {
            if (id != vol.ID_VOL)
            {
                return(BadRequest());
            }

            _context.Entry(vol).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VolExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public void Update(object id, Flight entity)
        {
            entity.Number = (string)id;
            var existedEntity = _ctx.Flights.Find(id);

            _ctx.Entry(existedEntity).CurrentValues.SetValues(entity);
        }
Ejemplo n.º 12
0
        public async Task Update(Ticket entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var oldEntity = await context.Tickets.FindAsync(entity.Id);

            if (oldEntity == null)
            {
                throw new NotFoundException(nameof(oldEntity));
            }
            context.Entry(oldEntity).State = EntityState.Detached;
            context.Entry(entity).State    = EntityState.Modified;
        }
Ejemplo n.º 13
0
        public void Update(object id, TEntity entity)
        {
            entity.Id = (int)id;
            var existedEntity = _ctx.Set <TEntity>().Find(id);

            _ctx.Entry(existedEntity).CurrentValues.SetValues(entity);
        }
Ejemplo n.º 14
0
        public void Update(Crew entity)
        {
            var item = GetItemByPredicate(x => x?.Id == entity?.Id);

            if (item == null)
            {
                return;
            }
            context.Entry(entity).CurrentValues.SetValues(item);
        }
Ejemplo n.º 15
0
        public bool Update(int id, Pilot obj)
        {
            var flag = db.Pilots.Count(item => item.Id == id) == 0;

            if (flag)
            {
                return(false);
            }
            obj.Id = id;
            db.Entry(obj).State = EntityState.Modified;
            return(true);
        }
Ejemplo n.º 16
0
        public void Update(Flight flight)
        {
            var _flight = _db.Flights.Find(flight.Id);

            if (_flight != null)
            {
                _db.Entry(_flight).CurrentValues.SetValues(flight);
                _db.SaveChanges();
            }
            else
            {
                throw new Exception("Current entity cannot be updated, because it doesn't exist");
            }
        }
        public List <Crews> GetAll()
        {
            var a = dataSource.CrewsList.ToList();

            foreach (Crews s in a)
            {
                dataSource.Entry(s).Reference(x => x.Pilot).Load();
                dataSource.Entry(s).Collection(x => x.StewardessList).Load();
            }
            return(a);
        }
        public List <Departures> GetAll()
        {
            var a = dataSource.DeparturesList.ToList();

            foreach (var t in a)
            {
                dataSource.Entry(t).Reference(x => x.Aircraft).Load();
                dataSource.Entry(t).Reference(x => x.Flight).Load();
                dataSource.Entry(t).Reference(x => x.Crew).Load();
            }
            return(a);
        }
Ejemplo n.º 19
0
 public void Edit(T entity)
 {
     context.Entry(entity).State = EntityState.Modified;
 }
Ejemplo n.º 20
0
 public virtual void Update(TEntity entity, string modifiedBy = null)
 {
     context.Set <TEntity>().Attach(entity);
     context.Entry(entity).State = EntityState.Modified;
 }
Ejemplo n.º 21
0
 public void Update(T entity)
 {
     _ctx.Entry(entity).State = EntityState.Modified;
     _dbSet.Attach(entity);
 }
Ejemplo n.º 22
0
 public void Update(Airport entity)
 {
     db.Entry(entity).State = EntityState.Modified;
 }
Ejemplo n.º 23
0
 public void Update(int id, Flight item)
 {
     _context.Entry(item).State = EntityState.Modified;
 }
Ejemplo n.º 24
0
 public virtual void UpdateItem(T item)
 {
     DB.Entry(item).State = EntityState.Modified;
 }