Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome in the Category Application");
            commandlist();
            string input = "";

            CategoryApp app = new CategoryApp();

            do
            {
                input = Console.ReadLine();
                Console.WriteLine("");
                switch (input)
                {
                case "help":
                    commandlist();
                    Console.WriteLine("");
                    break;

                case "category:list":
                    app.ShowList();
                    Console.WriteLine("");
                    break;

                case "category:add":
                    app.Add();
                    Console.WriteLine("");
                    break;

                case "category:show":
                    app.Show();
                    Console.WriteLine("");
                    break;

                case "category:update":
                    app.Update();
                    Console.WriteLine("");
                    break;

                case "category:delete":
                    app.Delete();
                    Console.WriteLine("");
                    break;

                default:
                    Console.WriteLine("Command not found in the list. Use help to show the list.");
                    Console.WriteLine("");
                    break;
                }
            }while(input != "stop");
            Console.WriteLine("Thank you for using this application!");
            Console.WriteLine("");
        }
        public Response Update(Category obj)
        {
            var result = new Response();

            try {
                _app.Update(obj);
            } catch (Exception ex) {
                result.Code    = 500;
                result.Message = ex.InnerException?.Message ?? ex.Message;
            }

            return(result);
        }
Exemple #3
0
        public string Update(AddOrUpdateCategoryReq obj)
        {
            Response resp = new Response();

            try
            {
                _app.Update(obj);
            }
            catch (Exception e)
            {
                resp.Code    = 500;
                resp.Message = e.Message;
            }
            return(JsonHelper.Instance.Serialize(resp));
        }