public async Task <ActionResult> Create([Bind(Include = "ClientCommandLogId,LogType,LogText,ClientCommandId")] ClientCommandLog clientcommandlog)
        {
            if (ModelState.IsValid)
            {
                db.ClientCommandLogs.Add(clientcommandlog);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new{ clientCommandId = clientcommandlog.ClientCommandId }));
            }

            return(View(clientcommandlog));
        }
コード例 #2
0
        public async Task <ActionResult> Create([Bind(Include = "ClientId,ClientName")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                try
                {
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateException dbUpdateException)
                {
                }
                catch (DbEntityValidationException dbEntityValidationException)
                {
                }
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
コード例 #3
0
        public async Task <ActionResult> Create([Bind(Include = "ClientCommandId,ClientId,Command,IsScheduled,IsExecuted")] NewCommandViewModel newCommandViewModel)
        {
            if (ModelState.IsValid)
            {
                ClientCommand clientcommand = JsonConvert.DeserializeObject <ClientCommand>(JsonConvert.SerializeObject(newCommandViewModel));
                clientcommand.IsExecuted = false;
                try
                {
                    clientcommand.ScheduledTime = new DateTime(newCommandViewModel.ScheduledDate.Value.Year, newCommandViewModel.ScheduledDate.Value.Month, newCommandViewModel.ScheduledDate.Value.Day, newCommandViewModel.ScheduledTime.Value.Hour, newCommandViewModel.ScheduledTime.Value.Minute, newCommandViewModel.ScheduledTime.Value.Second);
                }
                catch {}

                db.ClientCommands.Add(clientcommand);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { clientId = clientcommand.ClientId }));
            }

            return(View(newCommandViewModel));
        }