Exemplo n.º 1
0
 public IActionResult Create(Language language)
 {
     _context.Language.Add(language);
     _context.SaveChanges();
     return(new NoContentResult {
     });
 }
Exemplo n.º 2
0
        //
        // CREATE, Update, delete
        //

        public IActionResult Create(Client client)
        {
            //
            // @todo Adding a client which already exists with the same key, apikey, will throw a
            //       server 500 error here. This could be handled by the front-end but, it would also be nice
            //       if the back-end failed in a more gracefull manner, giving a better feedback on what
            //       went wrong - JSolsvik
            //
            _context.Client.Add(client);
            _context.SaveChanges();
            return(new StatusCodeResult(201));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        //
        // SET containers and langugaes on client
        //

        //
        // TESTDATA
        //
        public static void AddTestData(TranslationDb context)
        {
            context.Client.AddRange(
                new Client {
                Key = "FMSF", ApiKey = "1", ThumbnailUrl = "http://placehold.it/250x125/FFC107", WebpageUrl = "https://fmsf.plaholder.magic"
            },
                new Client {
                Key = "DIFI", ApiKey = "2", ThumbnailUrl = "http://placehold.it/250x125/FFC107", WebpageUrl = "https://difi.plaholder.magic"
            },
                new Client {
                Key = "Skatteetaten", ApiKey = "3", ThumbnailUrl = "http://placehold.it/250x125/FFC107", WebpageUrl = "https://skatteetaten.plaholder.magic"
            }
                );
            context.SaveChanges();
        }
Exemplo n.º 5
0
 //
 // TESTDATA
 //
 public static void AddTestData(TranslationDb context)
 {
     context.Language.AddRange(
         new Language {
         Name = "Norwegian", Key = "no-nb"
     },
         new Language {
         Name = "Swedish", Key = "sv"
     },
         new Language {
         Name = "Danish", Key = "da"
     },
         new Language {
         Name = "English", Key = "en"
     }
         );
     context.SaveChanges();
 }
Exemplo n.º 6
0
 //
 // TESTDATA translation
 //
 public static void AddTestData(TranslationDb context)
 {
     context.Translation.AddRange(
         new Translation {
         ClientKey = "FMSF", LanguageKey = "en", ContainerKey = "Main", Key = "hello_world", Text = "Hello World", IsComplete = true,
     },
         new Translation {
         ClientKey = "FMSF", LanguageKey = "no-nb", ContainerKey = "Main", Key = "hello_world", Text = "Hallo verden", IsComplete = false,
     },
         new Translation {
         ClientKey = "DIFI", LanguageKey = "en", ContainerKey = "Special", Key = "this_is_me", Text = "This is me!", IsComplete = false,
     },
         new Translation {
         ClientKey = "DIFI", LanguageKey = "no-nb", ContainerKey = "Special", Key = "this_is_me", Text = "Dette er meg!", IsComplete = true,
     }
         );
     context.SaveChanges();
 }
Exemplo n.º 7
0
 //
 // POST, PUT, DELETE translation
 //
 public IActionResult Create(Translation translation)
 {
     _context.Translation.Add(translation);
     _context.SaveChanges();
     return(new StatusCodeResult(201));
 }