示例#1
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));
            }
        }
示例#2
0
        public async Task <IActionResult> Create(CategoryGroups categoryGroups)
        {
            // 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";
                }

                _colibriDbContext.Add(categoryGroups);
                await _colibriDbContext.SaveChangesAsync();

                // Publish the Created Category
                using (var bus = RabbitHutch.CreateBus("host=localhost"))
                {
                    //bus.Publish(categoryGroups, "create_category_groups");
                    //await bus.PublishAsync("create_category_groups").ContinueWith(task =>
                    // {
                    //     if (task.IsCompleted && !task.IsFaulted)
                    //     {
                    //         Console.WriteLine("Task Completed");
                    //         Console.ReadLine();
                    //     }
                    // });
                    await bus.SendAsync("create_category_groups", categoryGroups);
                }


                // avoid Refreshing the POST Operation -> Redirect
                return(RedirectToAction(nameof(Index)));
                //return RedirectToAction("Index", "CategoryGroups", new { area = "Admin" });
            }
            else
            {
                // one can simply return to the Form View again for Correction
                return(View(categoryGroups));
            }
        }
示例#3
0
 private void HandleCategoryGroups(CategoryGroups categoryGroup)
 {
     SubscriberViewModel.Notifications.Message   = "Added a Category Group: " + categoryGroup.Name;
     SubscriberViewModel.Notifications.CreatedOn = DateTime.Now;
 }
示例#4
0
 private static void HandleRemovedCategoryGroupMessage(CategoryGroups obj2)
 {
     Console.WriteLine("Removed Category Name: {0}", obj2.Name);
 }
示例#5
0
 private static void HandleAddedCategoryGroupMessage(CategoryGroups obj1)
 {
     Console.WriteLine("Added Category Name: {0}", obj1.Name);
 }