public IActionResult SetClientLanguageArray(ClientQuery query, IEnumerable <ClientLanguage> clientLanguageArray) { var _clientLanguages = _context.ClientLanguage.Where(cl => cl.ClientKey == query.ClientKey); _context.RemoveRange(_clientLanguages); _context.SaveChanges(); _context.AddRange(clientLanguageArray); _context.SaveChanges(); return(new StatusCodeResult(201)); }
public IActionResult SetClientContainerArray(ClientQuery query, IEnumerable <ClientContainer> clientContainerArray) { var _clientContainers = _context.ClientContainer.Where(cc => cc.ClientKey == query.ClientKey); _context.RemoveRange(_clientContainers); _context.SaveChanges(); // If the foreign-key container does not exist,.. Add to Container table foreach (var cc in clientContainerArray) { if (_context.Container.Where(c => c.Key == cc.ContainerKey).Count() == 0) { _context.Container.Add(new Container { Key = cc.ContainerKey }); } } _context.AddRange(clientContainerArray); _context.SaveChanges(); return(new StatusCodeResult(201)); }