public async Task <IActionResult> PutDetail(Guid id, Detail detail)
        {
            if (id != detail.Detail_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutAddress(Guid id, Address address)
        {
            if (id != address.Address_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #3
0
        public async Task <IActionResult> PutContainer(Guid id, Container container)
        {
            if (id != container.Unit_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutRoute(Guid id, Route route)
        {
            if (id != route.Route_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #5
0
        public async Task <IActionResult> PutShipment(Guid id, Shipment shipment)
        {
            if (id != shipment.Shipment_Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public async Task UpdateShipment(Shipment shipment)
 {
     try
     {
         var entry = _dbContext.Shipments.First(e => e.ShipmentID == shipment.ShipmentID);
         _dbContext.Entry(entry).CurrentValues.SetValues(shipment);
         await _dbContext.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new KeyNotFoundException($"Shipment with Id:{shipment.ShipmentID} not found, cannot update");
         throw e;
     }
 }
Example #7
0
 public virtual void Update(T entity)
 {
     dbSet.Attach(entity);
     shipmentContext.Entry(entity).State = EntityState.Modified;
 }