Beispiel #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Name,PackageDescription,BackingAmount,RewardDescription,DateCreated,DateUpdated,ProjectId,AttatchmentSetId")] BackingPackage backingPackage)
        {
            if (id != backingPackage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(backingPackage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BackingPackageExists(backingPackage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AttatchmentSetId"] = new SelectList(_context.AttatchmentSet, "Id", "Id", backingPackage.AttatchmentSetId);
            ViewData["ProjectId"]        = new SelectList(_context.Project, "Id", "Name", backingPackage.ProjectId);
            return(View(backingPackage));
        }
Beispiel #2
0
        public async Task <IActionResult> Create(long projectId, [Bind("Id,Name,PackageDescription,BackingAmount,RewardDescription,DateCreated,DateUpdated,ProjectId,AttatchmentSetId")] BackingPackage backingPackage)
        {
            if (ModelState.IsValid)
            {
                backingPackage.DateCreated = DateTime.Now;
                _context.Add(backingPackage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ProjectsController.Details), "Projects", new { Id = backingPackage.ProjectId }));
            }
            return(View(backingPackage));
        }