Пример #1
0
        public async Task <IActionResult> Edit(int id, SpecialTags specialTags)
        {
            // the IDs should be equal
            if (id != specialTags.Id)
            {
                return(NotFound());
            }

            // Check the State Model Binding
            if (ModelState.IsValid)
            {
                // Update the Changes
                _colibriDbContext.Update(specialTags);
                await _colibriDbContext.SaveChangesAsync();

                // avoid Refreshing the POST Operation -> Redirect
                //return View("Details", newCategory);
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                // one can simply return to the Form View again for Correction
                return(View(specialTags));
            }
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, CategoryGroups categoryGroups)
        {
            // the IDs should be equal
            if (id != categoryGroups.Id)
            {
                return(NotFound());
            }

            // Check the State Model Binding
            if (ModelState.IsValid)
            {
                // Strings für TypeOfCategoryGroup schreiben
                if (categoryGroups.TypeOfCategoryGroup.Equals("0"))
                {
                    categoryGroups.TypeOfCategoryGroup = "Product";
                }
                else
                {
                    categoryGroups.TypeOfCategoryGroup = "Service";
                }

                // Update the Changes
                _colibriDbContext.Update(categoryGroups);
                await _colibriDbContext.SaveChangesAsync();

                // avoid Refreshing the POST Operation -> Redirect
                //return View("Details", newCategory);
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                // one can simply return to the Form View again for Correction
                return(View(categoryGroups));
            }
        }
Пример #3
0
        public async Task <IActionResult> EditPOST()
        {
            // i18n
            ViewData["ArchiveEntries"]      = _localizer["ArchiveEntriesText"];
            ViewData["Back"]                = _localizer["BackText"];
            ViewData["CategoryGroup"]       = _localizer["CategoryGroupText"];
            ViewData["CategoryType"]        = _localizer["CategoryTypeText"];
            ViewData["CreatedOn"]           = _localizer["CreatedOnText"];
            ViewData["CreateEntry"]         = _localizer["CreateEntryText"];
            ViewData["Create"]              = _localizer["CreateText"];
            ViewData["EditEntry"]           = _localizer["EditEntryText"];
            ViewData["IsOffer"]             = _localizer["IsOfferText"];
            ViewData["NewEntry"]            = _localizer["NewEntryText"];
            ViewData["Title"]               = _localizer["TitleText"];
            ViewData["TypeOfCategoryGroup"] = _localizer["TypeOfCategoryGroupText"];
            ViewData["Update"]              = _localizer["UpdateText"];
            ViewData["DeleteEntry"]         = _localizer["DeleteEntryText"];
            ViewData["Delete"]              = _localizer["DeleteText"];

            // Convert
            ArchiveViewModel.ArchiveEntry.CategoryTypeId = Convert.ToInt32(Request.Form["CategoryTypeId"].ToString());

            // Strings für TypeOfCategoryGroup schreiben
            if (ArchiveViewModel.ArchiveEntry.TypeOfCategoryGroup.Equals("0"))
            {
                ArchiveViewModel.ArchiveEntry.TypeOfCategoryGroup = "Product";
            }
            else
            {
                ArchiveViewModel.ArchiveEntry.TypeOfCategoryGroup = "Service";
            }

            //ArchiveViewModel.ArchiveEntry = await _colibriDbContext.ArchiveEntry.Include(m => m.CategoryGroups).Include(m => m.CategoryTypes).SingleOrDefaultAsync(m => m.Id == Ar);
            ArchiveViewModel.CategoryTypes = await _colibriDbContext.CategoryTypes.Where(s => s.CategoryGroupId == ArchiveViewModel.ArchiveEntry.CategoryGroupId).ToListAsync();

            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            var entryFromDb = _colibriDbContext.ArchiveEntry.Include(m => m.CategoryGroups).Where(m => m.Id == ArchiveViewModel.ArchiveEntry.Id).FirstOrDefault();

            entryFromDb.Name                = ArchiveViewModel.ArchiveEntry.Name;
            entryFromDb.CategoryGroupId     = ArchiveViewModel.ArchiveEntry.CategoryGroupId;
            entryFromDb.CategoryTypeId      = ArchiveViewModel.ArchiveEntry.CategoryTypeId;
            entryFromDb.isOffer             = ArchiveViewModel.ArchiveEntry.isOffer;
            entryFromDb.TypeOfCategoryGroup = ArchiveViewModel.ArchiveEntry.TypeOfCategoryGroup;

            _colibriDbContext.Update(entryFromDb);
            await _colibriDbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }