public async Task<IHttpActionResult> PutContact(int id, Contact contact)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

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

            db.Entry(contact).State = EntityState.Modified;

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

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
        //Populates the Contact table
        private void PopulateContact()
        {
            Contact sarina = new Contact()
            {
                id = 1,
                name = "Sarina",
                position = "",
                phone = "0031 20 30 80 749",
                email = "*****@*****.**"

            };

            Contact andreas = new Contact()
            {
                id = 2,
                name = "Andreas Köck",
                position = "",
                phone = "",
                email = "*****@*****.**"

            };

            Contact mads = new Contact()
            {
                id = 3,
                name = "Mads Bukholt",
                position = "",
                phone = "",
                email = "*****@*****.**"

            };

            Contact beconnected = new Contact()
            {
                id = 4,
                name = "",
                position = "",
                phone = "",
                email = ""

            };

            Contact emil = new Contact()
            {
                id = 5,
                name = "Emil Sebastian Pete",
                position = "",
                phone = "922 93 831",
                email = "*****@*****.**"
            };

            Contact anastasia = new Contact()
            {
                id = 6,
                name = "Mrs Anastasia Miliou",
                position = "Scientific Director",
                phone = "30 210 8253024",
                email = "*****@*****.**"
            };

            Contact thomas = new Contact()
            {
                id = 7,
                name = "Thomas Bang Torgersen",
                position = "",
                phone = "37 25 24 29",
                email = "*****@*****.**"
            };

            Contact alexander = new Contact()
            {
                id = 8,
                name = "Alexander Øren",
                position = "",
                phone = "",
                email = "*****@*****.**"
            };

            Contact svein = new Contact()
            {
                id = 9,
                name = "Svein Petter Undheim",
                position = "",
                phone = "",
                email = "*****@*****.**"
            };

            Contact yvonne = new Contact()
            {
                id = 10,
                name = "Yvonne Larsson",
                position = "",
                phone = "",
                email = "*****@*****.**"
            };


            db.contacts.Add(sarina);
            db.contacts.Add(andreas);
            db.contacts.Add(mads);
            db.contacts.Add(beconnected);
            db.contacts.Add(emil);
            db.contacts.Add(anastasia);
            db.contacts.Add(thomas);
            db.contacts.Add(alexander);
            db.contacts.Add(svein);
            db.contacts.Add(yvonne);
            db.SaveChanges();

        }
Пример #3
0
        public void ExtraData2()
        {
            Contact kirsti = new Contact()
            {
                id = 16,
                name = "Kirsti Lie",
                position = "",
                phone = "48264770",
                email = "*****@*****.**"
            };

            Company agderEnergi = new Company()
            {
                id = "agderEnergi",
                name = "Agder Energi",
                adress = "",
                url = "",
                facebook = "",
                linkedIn = "",
                description = "",
                logo = "http://kompetansetorget.uia.no/var/kompetansetorget/storage/images/virksomheter/agder-energi/10593-1-nor-NO/agder-energi_width-4.jpg"
            };

            db.contacts.Add(kirsti);
            db.companies.Add(agderEnergi);
            db.SaveChanges();

            Project strategi = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Fullstendig interaktiv 3D visualisering av Kraftstasjon (Tungefoss) med innlagte e-læringsressurser og dokumentasjon",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/utarbeiding-av-strategi-i-forbindelse-med-lansering-av-nytt-produkt",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 02, 08),
                published = new DateTime(2016, 02, 08),
                modified = new DateTime(2016, 02, 08),
                status = "Valgt"
            };

            StudyGroup data = db.studyGroup.First(x => x.id.Equals("datateknologi"));
            JobType virk = db.jobTypes.First(x => x.id.Equals("virksomhet"));
            Degree bach = db.degrees.First(x => x.id.Equals("bachelor"));
            Course dat303 = db.courses.First(x => x.id.Equals("DAT-303"));

            strategi.contacts.Add(kirsti);
            strategi.companies.Add(agderEnergi);
            strategi.jobTypes.Add(virk);
            strategi.studyGroups.Add(data);
            strategi.degrees.Add(bach);
            strategi.courses.Add(dat303);
            db.SaveChanges();
        }
Пример #4
0
        private void Extra()
        {
            Contact siri = new Contact()
            {
                id = 13,
                name = "Siri Håvås Haugland",
                position = "",
                phone = "",
                email = "*****@*****.**"
            };

            db.contacts.Add(siri);
            db.SaveChanges();

            Project informasjonsmateriell = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Utvikle informasjonsmateriell/pakke til forskningsseminar",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/utvikle-informasjonsmateriell-pakke-til-forskningsseminar",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 04, 15),
                published = new DateTime(2016, 04, 15),
                modified = new DateTime(2016, 04, 15),
                status = "Ledig"
            };
            Company uia = db.companies.First(x => x.id.Equals("uia"));
            JobType fagl = db.jobTypes.First(x => x.id.Equals("faglærer"));
            informasjonsmateriell.contacts.Add(siri);
            informasjonsmateriell.companies.Add(uia);
            informasjonsmateriell.jobTypes.Add(fagl);

            db.projects.Add(informasjonsmateriell);
            db.SaveChanges();

            Contact yngvar = new Contact()
            {
                id = 14,
                name = "Yngvar Asbjørn Olsen",
                position = "",
                phone = "",
                email = "*****@*****.**"
            };

            db.contacts.Add(yngvar);
            db.SaveChanges();

            Project gyrodactylus = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Utvikling av en metode for farging av Gyrodactylus spp in vitro",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/utvikling-av-en-metode-for-farging-av-gyrodactylus-spp-in-vitro",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 04, 16, 1, 1, 2),
                published = new DateTime(2016, 04, 16, 1, 1, 2),
                modified = new DateTime(2016, 04, 16, 1, 1, 2),
                status = "Ledig"
            };

            StudyGroup realfag = db.studyGroup.First(x => x.id.Equals("realfag"));
            Course bio300 = db.courses.First(x => x.id.Equals("BIO-300"));

            gyrodactylus.contacts.Add(yngvar);
            gyrodactylus.companies.Add(uia);
            gyrodactylus.jobTypes.Add(fagl);
            gyrodactylus.studyGroups.Add(realfag);
            gyrodactylus.courses.Add(bio300);

            db.projects.Add(gyrodactylus);
            db.SaveChanges();


            Contact erlend = new Contact()
            {
                id = 15,
                name = "Erlend Wangsteen",
                position = "",
                phone = "41009164",
                email = "*****@*****.**"
            };

            Company abnc = new Company()
            {
                id = "abnc",
                name = "abnc",
                adress = "",
                url = "",
                facebook = "",
                linkedIn = "",
                description = "",
                logo = "http://kompetansetorget.uia.no/extension/kompetansetorget/design/kompetansetorget/images/logo-virksomhet.jpg"
            };

            db.contacts.Add(erlend);
            db.companies.Add(abnc);
            db.SaveChanges();
            Project strategi = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Utarbeiding av strategi i forbindelse med lansering av nytt produkt.",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/utarbeiding-av-strategi-i-forbindelse-med-lansering-av-nytt-produkt",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 02, 16),
                published = new DateTime(2016, 02, 16),
                modified = new DateTime(2016, 02, 16),
                status = "Ledig"
            };

            StudyGroup admin = db.studyGroup.First(x => x.id.Equals("administrasjon"));
            JobType virk = db.jobTypes.First(x => x.id.Equals("virksomhet"));

            strategi.contacts.Add(erlend);
            strategi.companies.Add(abnc);
            strategi.jobTypes.Add(virk);
            strategi.studyGroups.Add(admin);

            db.projects.Add(strategi);
            db.SaveChanges();

            Project demohandelsplattform = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Konstruksjon av demo-handelsplattform",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/konstruksjon-av-demo-handelsplattform",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 02, 18),
                published = new DateTime(2016, 02, 18),
                modified = new DateTime(2016, 02, 18),
                status = "Ledig"
            };

            StudyGroup datateknologi = db.studyGroup.First(x => x.id.Equals("datateknologi"));
            demohandelsplattform.contacts.Add(erlend);
            demohandelsplattform.companies.Add(abnc);
            demohandelsplattform.jobTypes.Add(virk);
            demohandelsplattform.studyGroups.Add(datateknologi);

            db.projects.Add(demohandelsplattform);
            db.SaveChanges();

            Project handelsplattform = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Utarbeiding av derivater for internett-handelsplattform",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/utarbeiding-av-derivater-for-internett-handelsplattform",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 02, 16, 1, 1, 1),
                published = new DateTime(2016, 02, 16, 1, 1, 1),
                modified = new DateTime(2016, 02, 16, 1, 1, 1),
                status = "Ledig"
            };

            StudyGroup oko = db.studyGroup.First(x => x.id.Equals("økonomi"));
            handelsplattform.contacts.Add(erlend);
            handelsplattform.companies.Add(abnc);
            handelsplattform.jobTypes.Add(virk);
            handelsplattform.studyGroups.Add(oko);

            db.projects.Add(handelsplattform);
            db.SaveChanges();
        }
Пример #5
0
        private void temp()
        {
            Company etterIsoleringAgder = new Company()
            {
                id = "etterIsoleringAgder",
                name = "Etterisolering Agder AS",
                adress = "",
                url = "",
                facebook = "",
                linkedIn = "",
                description = "",
                logo = "http://kompetansetorget.uia.no/extension/kompetansetorget/design/kompetansetorget/images/logo-virksomhet.jpg"
            };

            Contact bjorn = new Contact()
            {
                id = 11,
                name = "Bjørn Ingebretsen",
                position = "styreleder",
                phone = "91564082",
                email = "*****@*****.**"

            };

            db.companies.Add(etterIsoleringAgder);
            db.contacts.Add(bjorn);
            db.SaveChanges();

            Project isolasjon = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Blåse isolasjon bak diffusjonsperre",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/blaase-isolasjon-bak-diffusjonsperre",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 05, 23),
                published = new DateTime(2016, 05, 23),
                modified = new DateTime(2016, 05, 23),
                status = "Ledig"
            };
            //Contact contact6 = db.contacts.First(x => x.id == 6);
            //Company uia = db.companies.First(x => x.id.Equals("uia"));
            //Degree bachelor = db.degrees.First(x => x.id.Equals("bachelor"));
            //StudyGroup realfag = db.studyGroup.First(x => x.id.Equals("realfag"));
            JobType virks = db.jobTypes.First(x => x.id.Equals("virksomhet"));
     
            isolasjon.contacts.Add(bjorn);
            isolasjon.companies.Add(etterIsoleringAgder);
            isolasjon.jobTypes.Add(virks);
            //pro1.studyGroups.Add(realfag);

            //pro1.degrees.Add(bachelor);
            //pro1.jobTypes.Add(fagl);


            db.projects.Add(isolasjon);
            db.SaveChanges();


            Company fia = new Company()
            {
                id = "fia",
                name = "Farm in Action",
                adress = "",
                url = "",
                facebook = "",
                linkedIn = "",
                description = "",
                logo = "http://kompetansetorget.uia.no/extension/kompetansetorget/design/kompetansetorget/images/logo-virksomhet.jpg"
            };

            Contact magnus = new Contact()
            {
                id = 12,
                name = "Magnus Gellein",
                position = "Faglig ansvarlig",
                phone = "94139095",
                email = "*****@*****.**"

            };

            db.companies.Add(fia);
            db.contacts.Add(magnus);
            db.SaveChanges();

            Project rusrehab = new Project()
            {
                uuid = Guid.NewGuid().ToString(),
                title = "Rusrehabilitering i InnPåTunet tiltak, med faglig oppfølgning inkludert.",
                description = "",
                webpage = "http://kompetansetorget.uia.no/oppgaver/rusrehabilitering-i-innpaatunet-tiltak-med-faglig-oppfoelgning-inkludert",
                linkedInProfile = "",
                stepsToApply = "",
                tutor = "",
                created = new DateTime(2016, 04, 16),
                published = new DateTime(2016, 04, 16),
                modified = new DateTime(2016, 04, 16),
                status = "Ledig"
            };

            Degree master = db.degrees.First(x => x.id.Equals("master"));
            StudyGroup helse = db.studyGroup.First(x => x.id.Equals("helse"));
            Course me504 = db.courses.First(x => x.id.Equals("ME-504"));


            rusrehab.contacts.Add(magnus);
            rusrehab.companies.Add(fia);
            rusrehab.jobTypes.Add(virks);
            rusrehab.degrees.Add(master);
            rusrehab.studyGroups.Add(helse);
            rusrehab.courses.Add(me504);


            //pro1.studyGroups.Add(realfag);

            //pro1.degrees.Add(bachelor);
            //pro1.jobTypes.Add(fagl);


            db.projects.Add(rusrehab);
            db.SaveChanges();
        }
        public async Task<IHttpActionResult> PostContact(Contact contact)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.contacts.Add(contact);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = contact.id }, contact);
        }