public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Address,PhoneNumber,RatingId")] ServiceMaintance serviceMaintance)
        {
            if (id != serviceMaintance.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(serviceMaintance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServiceMaintanceExists(serviceMaintance.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RatingId"] = new SelectList(_context.Rating, "Id", "Id", serviceMaintance.RatingId);
            return(View(serviceMaintance));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Description,Address,PhoneNumber,RatingId")] ServiceMaintance serviceMaintance)
        {
            if (ModelState.IsValid)
            {
                _context.Add(serviceMaintance);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RatingId"] = new SelectList(_context.Rating, "Id", "Id", serviceMaintance.RatingId);
            return(View(serviceMaintance));
        }
Example #3
0
        static void Main(string[] args)
        {
            //自维护代码
            if (ServiceMaintance.CheckMaintanceCmd(args))
            {
                return;
            }

            bool isServiceModel = Environment.UserInteractive ? false : true;

            // bool isServiceModel = Config.GetSystemConfig(ConfigConst.RunInServiceMode_Name, "false").ToLower() == "true";
            if (isServiceModel)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] { new DispatchNodeService() };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                Console.Write("服务管理 1:安装, 2:卸载  ,其它进入调试模式:");
                string s = Console.ReadLine();
                CurrServiceName = Config.GetSystemConfig(ConfigConst.ServiceName_Name, typeof(DispatchNodeService).FullName);

                switch (s)
                {
                case "1":
                    ServiceHelper.Install(CurrServiceName, Assembly.GetExecutingAssembly().Location);
                    Console.ReadKey();
                    break;

                case "2":
                    if (ServiceHelper.ServiceIsExisted(CurrServiceName))
                    {
                        ServiceHelper.Uninstall(CurrServiceName, Assembly.GetExecutingAssembly().Location);
                    }
                    Console.ReadKey();
                    break;

                default:
                    RLib.WatchLog.Loger.Log("正在启动...", "");
                    ServiceContainer sc = new DispatchContainer();
                    sc.Start();
                    RLib.WatchLog.Loger.Log("启动成功!", "");
                    Console.Read();
                    break;
                }
            }
        }