コード例 #1
0
        public async Task <ActionResult> Delete([Bind(Include = "Id,Timestamp")] Project project)
        {
            try
            {
                await projectRepo.DeleteAsync(project);

                return(RedirectToAction("Index"));
            }
            catch (DbUpdateConcurrencyException)
            {
                ModelState.AddModelError(string.Empty, $"Unable to delete record. Another user updated the record.");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, $"Unable to delete record: {ex.Message}");
            }
            ViewBag.ContractorId = new SelectList(contractorRepo.GetAll(), "Id", "Name", project.ContractorId);
            ViewBag.CustomerId   = new SelectList(customerRepo.GetAll(), "Id", "Name", project.CustomerId);
            ViewBag.ManagerId    = new SelectList(employeeRepo.GetAll(), "Id", "FullName", project.ManagerId);
            return(View(project));
        }