예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,MachineName,Status,Data")] Machine machine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(machine);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(machine));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Data,Status")] Device device)
        {
            if (ModelState.IsValid)
            {
                device.Id = Guid.NewGuid();
                db.Add(device);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(device));
        }
        public async Task <IActionResult> Create([Bind("Id,JoinedDate,Name,JobTitle,MonthlySalary,Department,ManagerId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ManagerId"] = new SelectList(_context.Employees, "Id", "Name", employee.ManagerId);
            return(View(employee));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,DateCreated,Author,Content,EmployeeId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                comment.Id = 0;
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Comments", new { Id = comment.EmployeeId }));
            }

            return(View(comment));
        }