public async Task <IActionResult> OnGetAsync() { var res = await _projectAppService.GetProjectViewModelForEditAsync(id); if (res == null) { return(NotFound()); } ProjectViewModel = res; return(Page()); }
public virtual async Task <ActionResult> Edit(ProjectEditViewModel model) { if (!ModelState.IsValid) { return(View(model)); } model.CreatorID = await GetCurrentUserIdAsync(); _projectService.EditProject(model); return(RedirectToAction(MVC.Project.ActionNames.Index)); }
public ActionResult Create() { ViewBag.UserId = personFacade .GetPeople(new PersonFilter { Email = User.Identity.Name }) .First().Id; var model = new ProjectEditViewModel() { Project = new ProjectDTO() }; return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,OwnerId,Code,EmployeeId,Description")] ProjectEditViewModel projectDTO) { if (id != projectDTO.Id) { return(NotFound()); } if (ModelState.IsValid) { var project = _mapper.Map <ProjectEditViewModel, Project>(projectDTO); try { _context.Update(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(project.Id)) { return(NotFound()); } else { throw; } } catch (DbUpdateException e) { var exception = e.InnerException; if (exception != null && exception.Message.Contains("IX_Projects_Name")) { ModelState.AddModelError("Name", "Проект уже существует"); } if (exception != null && exception.Message.Contains("IX_Projects_Code")) { ModelState.AddModelError("Code", "Такой код уже используется"); } } } ViewData["EmployeeId"] = new SelectList(_context.Employees .Where(x => x.Department.IsResponsibleProjectsAndSubProjects), "Id", "GetFullName"); ViewData["OwnerId"] = new SelectList(_context.Owners, "Id", "Name", projectDTO.OwnerId); return(View(projectDTO)); }
public ViewResult EditProject(int id) { Project project = _projectRepository.GetProject(id); ProjectEditViewModel projectEditViewModel = new ProjectEditViewModel { Id = project.Id, ProjectName = project.ProjectName, Status = project.Status, Description = project.Description, ExistingPhotoPath = project.PhotoPath }; return(View(projectEditViewModel)); }
public ViewResult Edit(int id) { Project project = _projectRepository.GetProject(id); ProjectEditViewModel projectEditView = new ProjectEditViewModel { Id = project.Id, ProjectID = project.ProjectID, Name = project.Name, Designer = project.Designer, Engineer = project.Engineer, Programmer = project.Programmer }; return(View(projectEditView)); }
public ActionResult Create(int?teamId, int?from) { var existProjectModel = new ProjectEditViewModel(); if (teamId.HasValue) { existProjectModel.Project.TeamId = teamId; } int userId = UserRepository.GetUserId(); var userCommunityTeams = TeamRepository.GetTeamsForManager(userId); existProjectModel.UserTeams = userCommunityTeams; return(View(existProjectModel)); }
[Route("Project/Edit")] //! I am not displaying the {id} parameter via this route public ActionResult Edit(Guid?id) { if (!id.HasValue || id.Value == Guid.Empty) { return(RedirectToAction(nameof(Index))); } ProjectEditViewModel model = GenerateEditViewModel(id); if (model == null) { return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ViewResult Edit(int id) { Project project = _projectRepository.GetProjectById(id); ProjectEditViewModel projectEditViewModel = new ProjectEditViewModel() { ProjectId = project.ProjectId, ProjectCreated = project.ProjectCreated, ProjectUpdated = project.ProjectUpdated, ProjectName = project.ProjectName, Status = project.Status, ProjectManager = project.ProjectManager, Description = project.Description }; return(View(projectEditViewModel)); }
public async Task <IActionResult> Edit(string id) { var projectFromDb = await this.adminService.GetProjectById(id); var project = new ProjectEditViewModel { Id = projectFromDb.Id, Name = projectFromDb.Name, Statuses = new List <ProjectStatus> { ProjectStatus.InProgress, ProjectStatus.Completed }, ProjectFiles = AutoMapper.Mapper.Map <IList <ProjectFileViewModel> >(projectFromDb.ProjectFiles), }; return(this.View(project)); }
private ProjectEditViewModel GenerateEditViewModel(Guid?id) { if (!id.HasValue || id.Value == Guid.Empty) { return(null); } Project foundProject = ProjectRepository.GetProject(id.Value); if (foundProject == null) { return(null); } return(ProjectEditViewModel.CreateNewViewModel(foundProject, UserRepository)); }
public IActionResult Create(ProjectEditViewModel data, string[] categoryList) { if (ModelState.IsValid) { Project project = new Project(); project.Id = Guid.NewGuid(); project.Title = data.Project.Title; project.Description = data.Project.Description; project.CreatedAt = DateTime.Now; project.UpdatedAt = DateTime.Now; projectRepository.Insert(project); projectRepository.Save(); using (var a = new AppDbContext(contextOptions)) { for (int i = 0; i < categoryList.Length; i++) { var category = a.Categories .Single(p => p.Id == Guid.Parse(categoryList[i])); a.Projects.Include(p => p.ProjectCategories).Single(p => p.Id == project.Id).ProjectCategories.Add(new ProjectCategory { Project = project, Category = category }); a.SaveChanges(); } } if (data.Images.Any()) { string uniqueFileName = ProcessUploadedFile(data, project); project.PhotoPath = uniqueFileName; } else { project.PhotoPath = null; } projectRepository.Update(project); projectRepository.Save(); TempData["Success"] = "Operation Successful!"; return(RedirectToAction("index")); } else { return(View("ProjectCreate", data)); } }
public IActionResult Edit(ProjectEditViewModel model) { //检查提供的数据是否有效,如果没有通过验证,需要重新编辑项目信息 //这样用户就可以更正并重新提交编辑表单 if (ModelState.IsValid) { Project project = _projectRepository.GetProject(model.Id); project.ProjectID = model.ProjectID; project.Name = model.Name; project.Designer = model.Designer; project.Engineer = model.Engineer; project.Programmer = model.Programmer; Project updateStudent = _projectRepository.Update(project); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <IActionResult> Edit(ProjectEditViewModel viewproject) { var project = viewproject.Project; if (project.ImagePath == null) { project.ImagePath = viewproject.ImagePath; } if (ModelState.IsValid) { _context.Update(project); await _context.SaveChangesAsync(); return(RedirectToAction("Chat", new { id = project.ProjectId })); } return(RedirectToAction("Edit", new { id = project.ProjectId })); }
public ActionResult Edit(int id, ProjectEditViewModel vm) { if (ModelState.IsValid) { try { if (BLL.UpdateProject(id, vm)) { return(RedirectToAction("GetTlProjects")); } ModelState.AddModelError("", "User does not exist"); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(View(vm)); }
public async Task <bool> TrySaveEditProjectViewModelAsync(ProjectEditViewModel projectEditViewModel) { try { var project = await _dbContext.Project.FirstOrDefaultAsync(m => m.ID == projectEditViewModel.ProjectId); project = _mapper.Map <ProjectEditViewModel, Project>(projectEditViewModel, project); _dbContext.Attach(project).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); return(true); } catch (Exception e) { System.Console.WriteLine(e.Message); return(false); } }
public async Task <IActionResult> Edit(ProjectEditViewModel input) { if (!ModelState.IsValid) { var employeeSelectListInfo = await this.employeesService.GetActiveEmployeesWithDepartment().To <ActiveEmployeeDepartmentViewModel>().ToListAsync(); List <string> departments = employeeSelectListInfo.Select(li => li.DepartmentName).Distinct().ToList(); var departmentGroups = departments.Select(d => new SelectListGroup { Name = d }); var participants = new List <SelectListItem>(); foreach (var department in departmentGroups) { var employees = employeeSelectListInfo.Where(esli => esli.DepartmentName == department.Name).ToList(); foreach (var employee in employees) { participants.Add( new SelectListItem { Value = employee.Id, Text = employee.FullName, Group = department }); } } ViewBag.Employees = participants; ViewBag.ProjectPositions = new SelectList(this.projectPositionsService.GetProjectPositions().ToList(), "Id", "Name"); return(this.View(input)); } var projectToEdit = input.To <ProjectEditDto>(); await this.projectsService.EditProjectAsync(projectToEdit); return(RedirectToAction("Details", "Projects", new { id = projectToEdit.Id })); }
public IHttpActionResult Put(ProjectEditViewModel project) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } try { ProjectDTO projectDto = new ProjectDTO(); Mapping.Mapping.Map(project, projectDto); _projectService.UpdateProject(projectDto); } catch (ValidationException e) { } return(Ok()); }
/// <summary> /// Handles the Loaded event of the TestCaseExecutionArrangmentView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void TestCaseExecutionArrangmentView_Loaded(object sender, RoutedEventArgs e) { if (isInitialized) { return; } this.ShowProgressBar(); Task t = Task.Factory.StartNew(() => { this.ProjectEditViewModel = new ProjectEditViewModel(); }); t.ContinueWith(antecedent => { this.DataContext = this.ProjectEditViewModel; this.HideProgressBar(); isInitialized = true; }, TaskScheduler.FromCurrentSynchronizationContext()); }
// GET: /Project/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectEditViewModel project = db.Projects .ProjectTo <ProjectEditViewModel>() .SingleOrDefault(p => p.ID == id); if (project == null) { return(HttpNotFound()); } ViewBag.CompanyID = new SelectList(db.Companies, "ID", "Name", project.CompanyID); ViewBag.PersonID = new SelectList(db.Persons, "ID", "FullName", project.PersonID); ViewBag.StageID = new SelectList(db.Stages, "ID", "StageName", project.StageID); return(View(project)); }
public async Task <IActionResult> Edit(int id) { Project projectFromDb = await _portfolioContext.Projects.Include(project => project.ProjectTags).FirstOrDefaultAsync(m => m.Id == id); ProjectEditViewModel vm = new ProjectEditViewModel() { Name = projectFromDb.Name, Description = projectFromDb.Description, SelectedTags = projectFromDb.ProjectTags.Select(mt => mt.TagId).ToArray() }; var tags = await _portfolioContext.Tags.ToListAsync(); vm.Tags = tags.Select(tag => new SelectListItem() { Value = tag.Id.ToString(), Text = tag.Name }).ToList(); return(View(vm)); }
public ActionResult CreateEdit(ProjectEditViewModel projectVM) { if (!ModelState.IsValid) { return(View(projectVM)); } if (projectVM.FeaturedImage != null) { using (var memoryStream = new MemoryStream()) { projectVM.FeaturedImage.CopyToAsync(memoryStream); projectVM.Project.Image = memoryStream.ToArray(); } } projectList.UpdateProject(projectVM.Project); return(RedirectToAction("Details", "Home", new { id = projectVM.Project.CampaignId })); }
public ViewResult Edit(int id) { Project project = _projectRepository.GetProject(id); ProjectEditViewModel projectEditView = new ProjectEditViewModel { Id = project.Id, ProjectID = project.ProjectID, Name = project.Name, Count = project.Count, Designer = project.Designer, Engineer = project.Engineer, Programmer = project.Programmer, Assembler = project.Assembler, DesignerScore = project.DesignerScore, EngineerScore = project.EngineerScore, ProgrammerScore = project.ProgrammerScore, AssemblerScore = project.AssemblerScore }; return(View(projectEditView)); }
//RemoveEpic methodunu yaz(EpicId alacak) public ActionResult Edit(int id, int?from) { var existProjectModel = new ProjectEditViewModel(); existProjectModel.Project = db.Projects.FirstOrDefault(x => x.ProjectId == id); if (TeamRepository.IsProjectManager(existProjectModel.Project.ProjectId)) { int userId = UserRepository.GetUserId(); var userCommunityTeams = TeamRepository.GetTeamsForManager(userId); existProjectModel.UserTeams = userCommunityTeams; existProjectModel.UserTeams = existProjectModel.UserTeams .GroupBy(x => x.TeamId) .Select(x => x.First()) .ToList(); return(View(existProjectModel)); } return(Content("You are not team manager, you cannot do this operation.")); }
public async Task <IActionResult> Edit(int id, ProjectEditViewModel model, string[] selectedCollaborators, string[] createdLinkLabels, string[] createdLinkUrls, string OldPhotoPath) { var currentUser = this.User.FindFirstValue(ClaimTypes.NameIdentifier); var project = await _context.Projects.FindAsync(id); if (id != model.ProjectID) { return(NotFound()); } if (ModelState.IsValid) { string uniqueFileName = OldPhotoPath; if (model.Photo != null) { uniqueFileName = ValidateImagePath(model); DeletePhoto(model); } project.Title = model.Title; project.Description = model.Description; project.StartDate = model.StartDate; project.EndDate = model.EndDate; project.CreationDate = model.CreationDate; project.PhotoPath = uniqueFileName; _context.Update(project); await _context.SaveChangesAsync(); await CreateCollaborators(selectedCollaborators, currentUser, project); if (!(createdLinkLabels[0] == null)) { CreateProjectLinks(createdLinkLabels, createdLinkUrls, project); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View()); }
// GET: Projects/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Project project = _context.Projects.Find(id); if (project == null) { return(HttpNotFound()); } ProjectEditViewModel vm = new ProjectEditViewModel(); vm.Title = project.Title; vm.Body = project.Body; vm.ExternalLink = project.ExternalLink; vm.SetCategoriesSelectList(_context.Categories.ToList()); return(View(vm)); }
public ActionResult GetProject(string projectId) { var project = ProjectService.GetProject(projectId); if (project == null) { throw new BusinessException("指定的项目不存在"); } var model = new ProjectEditViewModel(project, UserInfo); model.Attachments = ProjectService.GetProjectAttachments(projectId); model.CommentPageList = ProjectService.GetProjectCommentPageList(projectId, 1, 20); if (model.EnableManageFinance) { model.Budgets = GetBudgetViewModels(project.Id); } ProjectService.UpdateProjectViewStatusRead(projectId, UserInfo.UserId); return(JsonMessageResult(model)); }
public async Task <IActionResult> Edit(ProjectEditViewModel editView, int id) { Project projectFromDb = await _projectDbContext.Projects .Include(project => project.ProjectStatus) .Include(project => project.ProjectTags) .FirstOrDefaultAsync(p => p.Id == id); var projectStatuses = await _projectDbContext.ProjectStatuses.ToListAsync(); _projectDbContext.ProjectTags.RemoveRange(projectFromDb.ProjectTags); projectFromDb.Title = editView.Title; projectFromDb.Description = editView.Description; projectFromDb.ProjectStatusId = editView.SelectedProjectStatus; projectFromDb.ProjectTags = editView.SelectedTags.Select(tagId => new ProjectTag() { TagId = tagId }).ToList(); if (editView.Photo != null) { var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(editView.Photo.FileName); var pathName = Path.Combine(_hostingEnvironment.WebRootPath, "pics"); var fileNameWithPath = Path.Combine(pathName, uniqueFileName); using (var stream = new FileStream(fileNameWithPath, FileMode.Create)) { editView.Photo.CopyTo(stream); } projectFromDb.PhotoUrl = "/pics/" + uniqueFileName; } _projectDbContext.Update(projectFromDb); await _projectDbContext.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit(ProjectEditViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel).WithError("Project was unable to be saved successfully")); } Project project = Mapper.Map <ProjectEditViewModel, Project>(viewModel); if (viewModel.ID > 0) { _projectRepository.Update(project); } else { _projectRepository.Add(project); } await _projectRepository.SaveAsync(); return(RedirectToAction("Index").WithSuccess("Project was saved successfully")); }
public async Task <ProjectEditViewModel> GenerateProjectViewModel(int?projectId) { var projectVM = new ProjectEditViewModel(); projectVM.Members = await _member.GetAllMembersAsync(); if (projectId != null) { projectVM.Project = await _project.GetProjectByIdAsync((int)projectId); if (projectVM.Project.MemberId != null) { projectVM.Project.Member = projectVM.Members.FirstOrDefault(m => m.Id == projectVM.Project.MemberId); projectVM.Project.EncryptedMemberId = projectVM.Project.Member.EncryptedId; } } List <ProjectMember> projectMembers = await _projectMember.GetAllMembersForProjectAsync((int)projectId); List <Member> tempMembersAvailableToAdd = projectVM.Members.Where(m => m.Id != projectVM.Project.MemberId).ToList(); foreach (ProjectMember projectMember in projectMembers) { Member tempMemberAvailableToAdd = tempMembersAvailableToAdd.FirstOrDefault(temp => temp.Id == projectMember.MemberId); if (tempMemberAvailableToAdd != null) { tempMembersAvailableToAdd.Remove(tempMemberAvailableToAdd); } } projectVM.MembersAvailableToAdd = tempMembersAvailableToAdd; foreach (ProjectMember projectMember in projectMembers) { projectVM.MembersAvailableToRemove.Add(projectMember.Member); } return(projectVM); }