コード例 #1
0
        public static void Insertar <T>(T elemento) where T : class
        {
            var ctx = new TaskDbContext();

            ctx.Add <T>(elemento);
            ctx.SaveChanges();
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Title")] Models.Task task)
        {
            if (ModelState.IsValid)
            {
                _context.Add(task);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(task));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("CategoryID,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("TaskID,TaskName,DueDate,CategoryID")] Models.Task task)
        {
            if (ModelState.IsValid)
            {
                _context.Add(task);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Category, "CategoryID", "CategoryName", task.CategoryID);
            return(View(task));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("AthleticsMeetingsID,MeetingName,MeetingLocation,MeetingDate,MeetingCategoryID")] AthleticsMeetings athleticsMeetings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(athleticsMeetings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MeetingCategoryID"] = new SelectList(_context.MeetingCategory, "MeetingCategoryID", "CategoryName", athleticsMeetings.MeetingCategoryID);
            return(View(athleticsMeetings));
        }
コード例 #6
0
 public void Create(Login login)
 {
     context.Add(login);
 }
コード例 #7
0
 public static void InsertarSinGuardar <T>(T elemento, TaskDbContext ctx) where T : class
 {
     ctx.Add <T>(elemento);
 }