public async Task <ActionResult <Response> > RemoveCategory(RemoveCategory Id)
        {
            try {
                var result = await _dataService.RemoveCategory(Id.Id);

                if (result)
                {
                    return(new Response()
                    {
                        ResponseCode = HttpStatusCode.OK,
                        Data = result,
                        Status = result,
                        Message = "Removed successfully"
                    });
                }
                else
                {
                    return(new Response
                    {
                        Status = result,
                        Message = "Something went wrong from our part, and we are currently working on it.",
                        ResponseCode = HttpStatusCode.OK
                    });
                }
            }
            catch (Exception e)
            {
                return(new Response
                {
                    Status = false,
                    Message = "Something went wrong from our part, and we are currently working on it.",
                    ResponseCode = HttpStatusCode.OK
                });
            }
        }
        public async Task Remove_Category_Command_Should_Remove_Entity()
        {
            var user = new User(Guid.NewGuid(), "*****@*****.**");
            await _dbFixture.InsertAsync(user);

            var category = new Category(Guid.NewGuid(), "Category 1", user.Id);
            await _dbFixture.InsertAsync(category);

            var command     = new RemoveCategory(category.Id, category.Creator);
            var archiveTask = await _rabbitMqFixture.SubscribeAndGetAsync <CategoryRemoved, Category>(_dbFixture.GetEntityTask, command.Id);

            await _rabbitMqFixture.PublishAsync(command);

            var removedCategory = await archiveTask.Task;

            removedCategory.ShouldBeNull();
        }
 // DELETE api/<controller>/5
 public async Task Delete(long id)
 {
     var command = new RemoveCategory(id);
     await _commandBus.SendAsync(command);
 }
 private void RemoveCategoryBtn_Click(object sender, EventArgs e)
 {
     RemoveCategory?.Invoke(this, EventArgs.Empty);
 }
Exemple #5
0
        async Task LoadCategoriesDropdown()
        {
            try
            {
                DropdownItems.Clear();
                var CategoryListArr = new List <string>();
                using (SQLiteConnection con = new SQLiteConnection(@"Data Source=|DataDirectory|\Database.db"))
                {
                    con.Open();
                    SQLiteCommand    cmd      = new SQLiteCommand("SELECT * FROM Categories", con);
                    SQLiteDataReader reader   = cmd.ExecuteReader();
                    string[]         vnvalues = { "Category" };
                    while (reader.Read())
                    {
                        int i = 0;
                        foreach (string value in vnvalues)
                        {
                            if (!reader.IsDBNull(reader.GetOrdinal(value)))
                            {
                                CategoryListArr.Add(reader[value].ToString());
                            }
                            i++;
                        }
                    }
                    con.Close();
                }

                DropdownItems.AddRange(CategoryListArr);


                //return;

                //
                AddCategory.Clear();
                List <MenuItem> menuitmList = new List <MenuItem>();
                foreach (string categoryName in CategoryListArr)//this loop adds the text to the dropdown menu
                {
                    if (categoryName.ToString() != "All")
                    {
                        MenuItem menuitm2 = new MenuItem();
                        menuitm2.Header = categoryName;
                        menuitm2.Click += VisualNovelsListBox.ListInstance.AddToCategory;
                        //menuitm2.Command = AddToCategoryCommand;
                        //menuitm2.Click += VisualNovelsListbox.ListInstance.AddToCategory_Click;
                        menuitmList.Add(menuitm2);
                    }
                }
                AddCategory.AddMenuItemRange(menuitmList);


                RemoveCategory.Clear();
                menuitmList.Clear();
                foreach (string categoryName in CategoryListArr)//this loop adds the text to the dropdown menu
                {
                    if (categoryName.ToString() != "All")
                    {
                        MenuItem menuitm2 = new MenuItem();
                        menuitm2.Header = categoryName;
                        menuitm2.Click += VisualNovelsListBox.ListInstance.RemoveFromCategory;
                        menuitmList.Add(menuitm2);
                    }
                }
                RemoveCategory.AddMenuItemRange(menuitmList);
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = File.AppendText(StaticClass.CurrentDirectory + @"\debug.log"))
                {
                    sw.WriteLine(DateTime.Now);
                    sw.WriteLine("Exception Found:\tType: {0}", ex.GetType().FullName);
                    sw.WriteLine("Class File: VnListBoxViewModel.cs");
                    sw.WriteLine("Method Name: LoadCategoriesDropdown");
                    sw.WriteLine("\nMessage: {0}", ex.Message);
                    sw.WriteLine("Source: {0}", ex.Source);
                    sw.WriteLine("StackTrace: {0}", ex.StackTrace);
                    sw.WriteLine("Target Site: {0}", ex.TargetSite);


                    sw.WriteLine("\n\n");
                }
                throw;
            }
        }