public async Task <IActionResult> Edit(int id, [Bind("ModelProjectId,ModelName,ModelDescription")] ModelProject modelProject)
        {
            if (id != modelProject.ModelProjectId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(modelProject);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModelProjectExists(modelProject.ModelProjectId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(modelProject));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonId,FirstName,LastName,MiddleName,Address,Email,OwnersLicenseId,Address2,ProvinceId,PostalCode,PhoneNumber,PersonImage")] Person person)
        {
            if (id != person.PersonId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.PersonId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnersLicenseId"] = new SelectList(_context.OwnersLicense, "OwnersLicenseId", "Active", person.OwnersLicenseId);
            ViewData["ProvinceId"]      = new SelectList(_context.Province, "ProvinceId", "ProvinceCode", person.ProvinceId);
            return(View(person));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,PersonId,EmployeeNumber")] Employee employee)
        {
            if (id != employee.EmployeeId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmployeeId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            Create();
            return(View(employee));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ModelProjectId,ModelName,ModelDescription")] ModelProject modelProject)
        {
            if (id != modelProject.ModelProjectId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(modelProject);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ModelProjectExists(modelProject.ModelProjectId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(modelProject));
        }
Esempio n. 5
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskInfoId,TaskId,TaskNote")] TaskInfo taskInfo)
        {
            if (id != taskInfo.TaskInfoId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskInfoExists(taskInfo.TaskInfoId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TaskId"] = new SelectList(_context.Task, "TaskId", "TaskDescription", taskInfo.TaskId);
            return(View(taskInfo));
        }
Esempio n. 6
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonId,FirstName,LastName,MiddleName,Address,Email,OwnersLicenseId,Address2,ProvinceId,PostalCode,PhoneNumber,PersonImage")] Person person, IFormFile PersonImage)
        {
            if (id != person.PersonId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (PersonImage != null)
                    {
                        using (var stream = new MemoryStream())
                        {
                            await PersonImage.CopyToAsync(stream);

                            person.PersonImage      = stream.ToArray();
                            person.ImageContentType = PersonImage.ContentType;
                        }
                    }

                    _context.Update(person);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.PersonId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction("index", "projects"));
            }
            Create();
            return(View(person));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("ProjectId,ClientId,EmployeeId,ProjectOpen,ProjectName,StartDate,EndDate,ProjectDescription")] Project project)
        {
            if (id != project.ProjectId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ProjectId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"An error has happen on editing. {e.GetBaseException().Message}");
                }
                TempData["message"] = "The project has been updated.";
                return(RedirectToAction(nameof(Index)));
            }
            Create();
            return(View(project));
        }
Esempio n. 8
0
        public async Task <IActionResult> Edit(int id, [Bind("OwnersLicenseId,CompanyName,ExpireDate,Active,LicenseEmail")] OwnersLicense ownersLicense)
        {
            if (id != ownersLicense.OwnersLicenseId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ownersLicense);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnersLicenseExists(ownersLicense.OwnersLicenseId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction(nameof(Index)));
            }
            Create();
            return(View(ownersLicense));
        }
Esempio n. 9
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskId,EmployeeId,TaskListId,TaskName,TaskWeight,TaskDescription,ExpectedDate,TaskDuration,TaskActiveFlag")] Models.Task task)
        {
            if (id != task.TaskId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(task);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskExists(task.TaskId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction("index", "tasklist"));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "EmployeeId", "EmployeeId", task.EmployeeId);
            ViewData["TaskListId"] = new SelectList(_context.TaskList, "TaskListId", "TaskListId", task.TaskListId);
            return(View(task));
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskListId,TaskListName,ProjectId,TaskListOpen")] TaskList taskList)
        {
            if (id != taskList.TaskListId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskList);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskListExists(taskList.TaskListId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (Exception e)
                {
                    TempData["message"] = $"Edit error: {e.GetBaseException().Message}";
                }


                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProjectId"] = new SelectList(_context.Project, "ProjectId", "ProjectDescription", taskList.ProjectId);
            return(View(taskList));
        }
Esempio n. 11
0
        public async Task <IActionResult> Edit(int id, [Bind("ProvinceId,ProvinceName,ProvinceCode,CountryId")] Province province)
        {
            if (id != province.ProvinceId)
            {
                ModelState.AddModelError("", "Invalid ID, please try again.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(province);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "The record has been successfully updated";
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProvinceExists(province.ProvinceId))
                    {
                        ModelState.AddModelError("", "The record does not exist, try again");
                    }
                    else
                    {
                        ModelState.AddModelError("", "This record has already been updated");
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", $"Error on Edit: {e.GetBaseException().Message}");
                }
                return(RedirectToAction(nameof(Index)));
            }
            Create();
            return(View(province));
        }