コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ProjectId,Title,Description,CreateDate,EndDate,DeliveryDate,CustomerId")] Project project)
        {
            if (id != project.ProjectId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ProjectId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "Name", project.CustomerId);
            return(View(project));
        }
コード例 #2
0
ファイル: CustomersController.cs プロジェクト: avarantes/VPM
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,Name,VatNumber,Address,ZipCode")] Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskId,Title,Description,BillableTime,CreateDate,EndDate,ProjectId, CostPerHour")] Models.Task task)
        {
            if (id != task.TaskId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    task.TaskCost = CalculateTaskCost(task);
                    _context.Update(task);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.TaskId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"] = new SelectList(_context.Projects, "ProjectId", "ProjectId", task.ProjectId);
            return(View(task));
        }