Ejemplo n.º 1
0
        public async Task <List <NotenModel> > GetNoten()
        {
            try
            {
                var data = await NotenProcessor.LoadNotenAsync(ConnectionString);

                List <NotenModel> ViewListeNoten = new List <NotenModel>();

                foreach (var item in data)
                {
                    ViewListeNoten.Add(
                        new NotenModel
                    {
                        NId                = item.NId,
                        Bezeichnung        = item.Bezeichnung,
                        Mindestanforderung = item.Mindestanforderung
                    }
                        );
                }
                return(ViewListeNoten);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public async Task DeleteNote(int id)
 {
     try
     {
         NotenProcessor.DeleteNoteAsync(id, ConnectionString);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Ejemplo n.º 3
0
        public async Task <bool> PutNoteAsync(int id, NotenDLModel note)
        {
            try
            {
                var d = await NotenProcessor.SaveNoteAsync(id, note, ConnectionString);

                return(d);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete_Post(int id)
        {
            try
            {
                await NotenProcessor.DeleteNoteAsync(id, ConnectionString);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, NotenDLModel changednote)
        {
            try
            {
                await NotenProcessor.SaveNoteAsync(id, changednote, ConnectionString);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create(NotenModel neuenote)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await NotenProcessor.CreateNoteAsync(neuenote.NId, neuenote.Bezeichnung, neuenote.Mindestanforderung, ConnectionString);
                }

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 7
0
        public async Task <bool> PostNote(NotenModel note)
        {
            try
            {
                var b = await NotenProcessor.CreateNoteAsync(
                    note.NId,
                    note.Bezeichnung,
                    note.Mindestanforderung,
                    ConnectionString);

                return(b);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 8
0
        public async Task <NotenModel> GetNoteAsync(int id)
        {
            try
            {
                NotenDLModel resultnote = await NotenProcessor.GetByIdNoteAsync(id, ConnectionString);

                NotenModel note =
                    new NotenModel
                {
                    NId                = resultnote.NId,
                    Bezeichnung        = resultnote.Bezeichnung,
                    Mindestanforderung = resultnote.Mindestanforderung
                };

                return(note);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }