Пример #1
0
        public IActionResult Index()
        {
            var liste = GerichtService.All();

            var vm = new GerichtServiceIndexViewModel
            {
                Alle = liste
            };

            return(View(vm));
        }
Пример #2
0
        public IActionResult Index()
        {
            var liste = GerichtService.All();

            var vm = new IndexViewModel
            {
                Random = GerichtService.Random(),
                Alle   = liste,
                Tags   = TagService.All(),
                Filter = new FilterSettings()
            };

            return(View(vm));
        }
Пример #3
0
        public IActionResult Edit(Guid guid)
        {
            var dbEntry = GerichtService.Single(guid);

            if (dbEntry == null)
            {
                return(RedirectToAction("Index"));
            }

            var vm = new CreateEditViewModel
            {
                Gericht       = dbEntry,
                AvailableTags = TagService.All()
            };

            return(View(vm));
        }
Пример #4
0
        public IActionResult Create(CreateEditViewModel vm)
        {
            var tags       = TagService.All();
            var newGericht = vm.Gericht;

            newGericht.Tags = new List <Tag>();

            if (vm.SelectedTagGuids != null)
            {
                foreach (var tagGuid in vm.SelectedTagGuids)
                {
                    if (tags.Single(c => c.Guid == tagGuid) != null)
                    {
                        newGericht.Tags.Add(tags.Single(c => c.Guid == tagGuid));
                    }
                }
            }

            GerichtService.Create(newGericht);
            return(RedirectToAction("Index"));
        }
Пример #5
0
 public HomeController()
 {
     GerichtService = new GerichtService();
     TagService     = new TagService();
 }
Пример #6
0
 public IActionResult Delete(Guid guid)
 {
     GerichtService.Delete(guid);
     return(RedirectToAction("Index"));
 }