Exemple #1
0
        public async Task <IActionResult> PutMake(int id, Make make)
        {
            if (id != make.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutFeature([FromRoute] int id, [FromBody] Feature feature)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != feature.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #3
0
 public void InsertOrUpdate(FabricationOrder fabricationOrder)
 {
     if (fabricationOrder.Id == default(int))
     {
         VegaContext.FabricationOrders.Add(fabricationOrder);
     }
     else
     {
         VegaContext.Entry(fabricationOrder).State = EntityState.Modified;
     }
 }
Exemple #4
0
 public void InsertOrUpdate(ImportingInvoice importingInvoice)
 {
     if (importingInvoice.Id == default(int))
     {
         VegaContext.ImportingInvoices.Add(importingInvoice);
     }
     else
     {
         VegaContext.Entry(importingInvoice).State = EntityState.Modified;
     }
 }
Exemple #5
0
 public void InsertOrUpdate(UGroupPermission permission)
 {
     if (permission.Id == default(int))
     {
         VegaContext.UGroupPermissions.Add(permission);
     }
     else
     {
         VegaContext.Entry(permission).State = EntityState.Modified;
     }
 }
 public void InsertOrUpdate(RawMaterial rawMaterial)
 {
     if (rawMaterial.ID == default(int))
     {
         VegaContext.RawMaterials.Add(rawMaterial);
     }
     else
     {
         VegaContext.Entry(rawMaterial).State = EntityState.Modified;
     }
 }
 public void InsertOrUpdate(ProgressionCheck progressionCheck)
 {
     if (progressionCheck.ID == default(int))
     {
         VegaContext.ProgressionChecks.Add(progressionCheck);
     }
     else
     {
         VegaContext.Entry(progressionCheck).State = EntityState.Modified;
     }
 }
Exemple #8
0
 public void InsertOrUpdate(Suplier suplier)
 {
     if (suplier.Id == default(int))
     {
         VegaContext.Supliers.Add(suplier);
     }
     else
     {
         VegaContext.Entry(suplier).State = EntityState.Modified;
     }
 }
Exemple #9
0
 public void InsertOrUpdate(UGroup uGroup)
 {
     if (uGroup.Id == default(int))
     {
         VegaContext.UGroups.Add(uGroup);
     }
     else
     {
         VegaContext.Entry(uGroup).State = EntityState.Modified;
     }
 }
Exemple #10
0
 public void InsertOrUpdate(Component component)
 {
     if (component.Id == default(int))
     {
         VegaContext.Components.Add(component);
     }
     else
     {
         VegaContext.Entry(component).State = EntityState.Modified;
     }
 }
Exemple #11
0
 public void InsertOrUpdate(Message message)
 {
     if (message.Id == default(int))
     {
         VegaContext.Messages.Add(message);
     }
     else
     {
         VegaContext.Entry(message).State = EntityState.Modified;
     }
 }
Exemple #12
0
 public void InsertOrUpdate(Expence expence)
 {
     if (expence.Id == default(int))
     {
         VegaContext.Expences.Add(expence);
     }
     else
     {
         VegaContext.Entry(expence).State = EntityState.Modified;
     }
 }
Exemple #13
0
 public void InsertOrUpdate(Task task)
 {
     if (task.Id == default(int))
     {
         VegaContext.Tasks.Add(task);
     }
     else
     {
         VegaContext.Entry(task).State = EntityState.Modified;
     }
 }
Exemple #14
0
 public void InsertOrUpdate(NomenclatureSequance ns)
 {
     if (ns.ID == default(int))
     {
         VegaContext.NomenclatureSequances.Add(ns);
     }
     else
     {
         VegaContext.Entry(ns).State = EntityState.Modified;
     }
 }
Exemple #15
0
 public void InsertOrUpdate(User user)
 {
     if (user.Id == default(int))
     {
         VegaContext.Users.Add(user);
     }
     else
     {
         VegaContext.Entry(user).State = EntityState.Modified;
     }
 }
 public void InsertOrUpdate(UsedRawMaterial usedRM)
 {
     if (usedRM.Id == default(int))
     {
         VegaContext.UsedRawMaterials.Add(usedRM);
     }
     else
     {
         VegaContext.Entry(usedRM).State = EntityState.Modified;
     }
 }
Exemple #17
0
 public void InsertOrUpdate(NColor color)
 {
     if (color.Id == default(int))
     {
         VegaContext.NColors.Add(color);
     }
     else
     {
         VegaContext.Entry(color).State = EntityState.Modified;
     }
 }
Exemple #18
0
 public void InsertOrUpdate(Nomenclature nomenclature)
 {
     if (nomenclature.Id == default(int))
     {
         VegaContext.Nomenclatures.Add(nomenclature);
     }
     else
     {
         VegaContext.Entry(nomenclature).State = EntityState.Modified;
     }
 }
 public void InsertOrUpdate(SellingInvoice sellingInvoice)
 {
     if (sellingInvoice.Id == default(int))
     {
         VegaContext.SellingInvoices.Add(sellingInvoice);
     }
     else
     {
         VegaContext.Entry(sellingInvoice).State = EntityState.Modified;
     }
 }
Exemple #20
0
        public async Task <IActionResult> PutFeature(Feature item)
        {
            int id = _context.Features.Where(f => f.id == item.id).Select(y => y.id).FirstOrDefault();

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

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemple #21
0
        public async Task <IActionResult> PutVehicle(int id, VehicleVM vehicleVM)
        {
            if (id != vehicleVM.Id)
            {
                return(BadRequest());
            }
            var vehicle = new Vehicle()
            {
                Id              = vehicleVM.Id,
                ModelId         = vehicleVM.ModelId,
                Model           = _context.Models.FirstOrDefault(m => m.Id == vehicleVM.ModelId),
                IsRegistered    = vehicleVM.IsRegistered,
                ContactName     = vehicleVM.ContactName,
                ContactPhone    = vehicleVM.ContactPhone,
                ContactEmail    = vehicleVM.ContactEmail,
                LastUpdated     = DateTime.UtcNow,
                MoreInfo        = vehicleVM.MoreInfo,
                VehicleFeatures = vehicleVM.VehicleFeatures.Select(f => new VehicleFeature {
                    FeatureId = f, VehicleId = vehicleVM.Id
                }).ToList()
            };

            var features = _context.VehicleFeatures.Where(v => v.VehicleId == vehicle.Id);

            _context.VehicleFeatures.RemoveRange(features);
            _context.VehicleFeatures.AddRange(vehicle.VehicleFeatures);

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

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

            return(Ok(vehicle));
        }
 public void Update(T obj)
 {
     table.Attach(obj);
     _context.Entry(obj).State = EntityState.Modified;
 }