Example #1
0
        public async Task <IActionResult> PutListVendors(int id, ListVendors listVendors)
        {
            if (id != listVendors.VendorId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <ActionResult <ListVendors> > PostListVendors(ListVendors listVendors)
        {
            _context.ListVendors.Add(listVendors);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetListVendors", new { id = listVendors.VendorId }, listVendors));
        }
Example #3
0
 public void AddOrDeleteVendor(Vendor vendor, bool wishToAdd)
 {
     if (wishToAdd.Equals(true))
     {
         if (!ListVendors.Contains(vendor))
         {
             ListVendors.Add(vendor);
         }
         else
         {
             Console.WriteLine($"Impossible to add the vendor {vendor.LastName} {vendor.FirstName} a second time.");
         }
     }
     else
     {
         if (ListVendors.Contains(vendor))
         {
             ListVendors.Remove(vendor);
         }
         else
         {
             Console.WriteLine($"Impossible to remove the vendor {vendor.LastName} {vendor.FirstName} while he isn't present.");
         }
     }
 }