public int Create(string vorname, string nachname, string mail)
 {
     var newItem = new Gutachter {  EMail = mail, Nachname = nachname, Vorname = vorname };
     _context.Gutachter.Add(newItem);
     _context.SaveChanges();
     return newItem.Id;
 }
 public void Update(Gutachter gutachter)
 {
     var gutachterToChagne = DemoData.FirstOrDefault(c => c.Id == gutachter.Id);
     if (gutachterToChagne != null)
     {
         gutachterToChagne.Vorname = gutachterToChagne.Vorname;
         gutachterToChagne.Nachname = gutachterToChagne.Nachname;
         gutachterToChagne.EMail = gutachterToChagne.EMail;
     }
 }
        // POST api/values
        public HttpResponseMessage Post(Gutachter gutachter)
        {
            var newId = _repository.Create(gutachter.Vorname, gutachter.Nachname, gutachter.EMail);

            return Request.CreateResponse(HttpStatusCode.Created,
                "{ Id: " + newId + ", "
               + "  '_links': {"
               + "      'self':   { 'href': '/api/Gutachter/'" + newId + " }"
               + "}");
        }
        public int Create(string vorname, string nachname, string mail)
        {
            var newItem = new Gutachter {
                EMail = mail, Nachname = nachname, Vorname = vorname
            };

            _context.Gutachter.Add(newItem);
            _context.SaveChanges();
            return(newItem.Id);
        }
예제 #5
0
        public void Update(Gutachter gutachter)
        {
            var gutachterToChagne = DemoData.FirstOrDefault(c => c.Id == gutachter.Id);

            if (gutachterToChagne != null)
            {
                gutachterToChagne.Vorname  = gutachterToChagne.Vorname;
                gutachterToChagne.Nachname = gutachterToChagne.Nachname;
                gutachterToChagne.EMail    = gutachterToChagne.EMail;
            }
        }
        public void Update(Gutachter gutachter)
        {
            var value = Read(gutachter.Id);

            if (value != null)
            {
                value.EMail = gutachter.EMail;
                value.Vorname = gutachter.Vorname;
                value.Nachname = gutachter.Nachname;
                _context.SaveChanges();
            }
        }
        public void Update(Gutachter gutachter)
        {
            var value = Read(gutachter.Id);

            if (value != null)
            {
                value.EMail    = gutachter.EMail;
                value.Vorname  = gutachter.Vorname;
                value.Nachname = gutachter.Nachname;
                _context.SaveChanges();
            }
        }
예제 #8
0
        public int Create(string vorname, string nachname, string mail)
        {
            int newId = DemoData.Max(c => c.Id);

            var gutachter = new Gutachter
            {
                Id       = newId,
                Vorname  = vorname,
                Nachname = nachname,
                EMail    = mail
            };

            DemoData.Add(gutachter);
            return(newId);
        }
        public int Create(string vorname, string nachname, string mail)
        {
            int newId = DemoData.Max(c => c.Id);

            var gutachter = new Gutachter
                            {
                                Id = newId,
                                Vorname = vorname,
                                Nachname = nachname,
                                EMail = mail
                            };

            DemoData.Add(gutachter);
            return newId;
        }
        public void Init()
        {
            var klaus = new Gutachter { Id= 2, Vorname = "Klaus"};
            klaus.Gutachten.Add(new Gutachten());

            _inMemoryDbSet = new InMemoryDbSet<Gutachter>(true)
                             {
                                 new Gutachter { Id = 1, Vorname = "Hans" },
                                 klaus,
                                 new Gutachter { Id = 3, Vorname = "Inge" }
                             };

            _mockedContext = new Mock<IDashboardContext>();
            _mockedContext.Setup(x => x.Gutachter).Returns(_inMemoryDbSet);
            _sut = new GutachterRepository(_mockedContext.Object);
        }
 // PUT api/values/5
 public void Put(Gutachter gutachter)
 {
     _repository.Update(gutachter);
 }
        public void Update_modifies_item_in_db()
        {
            var changedData = new Gutachter
            {
                Id = 2,
                Nachname = "TEST",
                Vorname = "TEST",
                EMail = "*****@*****.**"
            };

            _sut.Update(changedData);

            Gutachter vorherKlaus = _inMemoryDbSet.First(x => x.Id == 2);

            Assert.That(vorherKlaus.Vorname, Is.EqualTo(changedData.Vorname), "Vorname should change");
            Assert.That(vorherKlaus.Nachname, Is.EqualTo(changedData.Nachname), "Nachname should change");
            Assert.That(vorherKlaus.EMail, Is.EqualTo(changedData.EMail), "EMail should change");
            Assert.That(vorherKlaus.Gutachten.Count, Is.EqualTo(1), "Gutachten should not be changed");

            _mockedContext.Verify(x => x.SaveChanges(), Times.Once());
        }