public async Task <IActionResult> Edit(EditProjectViewModel viewModel) { var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId); try { await ProjectService.EditProject(new EditProjectRequest { ProjectId = viewModel.ProjectId, ClaimApplyRules = viewModel.ClaimApplyRules, IsAcceptingClaims = viewModel.IsAcceptingClaims, MultipleCharacters = !viewModel.StrictlyOneCharacter, ProjectAnnounce = viewModel.ProjectAnnounce, ProjectName = viewModel.ProjectName, PublishPlot = viewModel.PublishPlot, AutoAcceptClaims = viewModel.AutoAcceptClaims, IsAccommodationEnabled = viewModel.EnableAccomodation, }); return(RedirectTo(project)); } catch { viewModel.OriginalName = project.ProjectName; return(View(viewModel)); } }
public async Task <IHttpActionResult> Update(EditProjectViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dto = _mapper.Map <EditProjectViewModel, EditProjectDto>(viewModel); SetOrganizationAndUser(dto); try { await _projectsService.EditProject(dto); return(Ok()); } catch (ValidationException e) { return(BadRequestWithError(e)); } catch (UnauthorizedException) { return(Forbidden()); } }
public ActionResult Edit(int id) { Project project = _context.Projects.Where(x => x.Id == id).FirstOrDefault(); if (project == null) { return(RedirectToAction("Index", "Error")); } HashSet <int> TagHash = new HashSet <int>(); foreach (var tag in _context.ProjectTags.Where(x => x.ProjectId == id).ToList()) { TagHash.Add(tag.TagId); } EditProjectViewModel vm = new EditProjectViewModel { Id = project.Id, AuthorId = project.AuthorId, Name = project.Name, Description = project.Description, Authors = _context.Authors.ToList(), Tags = _context.Tags.ToList(), TagHash = TagHash, ProjectImages = _context.ProjectImages.Where(x => x.ProjectId == project.Id).ToList() }; return(View(vm)); }
public async Task <IActionResult> Edit(int id, EditProjectViewModel model) { if (!ModelState.IsValid) { model.Items = PopulateProjectByEdit(model.Id); return(View(model)); } if (IsProjectNameExitsByEdit(model.ProjectName, model.Id) == false) { ModelState.AddModelError(string.Empty, "项目名称已经存在"); } if (ModelState.ErrorCount > 0) { model.Items = PopulateProjectByEdit(model.Id); return(View(model)); } var dbProject = _hdDbContext.Projects.FirstOrDefault(t => t.Id == model.Id); var dbGroup = _hdDbContext.Groups.FirstOrDefault(t => t.Id == int.Parse(model.GroupId)); dbProject.Name = model.ProjectName; dbProject.GroupId = dbGroup.Id; dbProject.Group = dbGroup; _hdDbContext.Update(dbProject); await _hdDbContext.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult Edit(int?id) { if (!id.HasValue) { return(RedirectToAction(nameof(ProjectController.Index))); } var userId = User.Identity.GetUserId(); var post = DbContext.Projects.FirstOrDefault( p => p.ID == id && p.ID == id); if (post == null) { return(RedirectToAction(nameof(ProjectController.Index))); } var model = new EditProjectViewModel { ProjectName = post.ProjectName, Description = post.Description }; DbContext.SaveChanges(); return(View(model)); }
public async Task <ActionResult> Edit(EditProjectViewModel viewModel) { var project = await ProjectRepository.GetProjectAsync(viewModel.ProjectId); var errorResult = AsMaster(project, pacl => pacl.CanChangeProjectProperties); if (errorResult != null) { return(errorResult); } try { await ProjectService.EditProject(viewModel.ProjectId, CurrentUserId, viewModel.ProjectName, viewModel.ClaimApplyRules, viewModel.ProjectAnnounce, viewModel.IsAcceptingClaims, viewModel.EnableManyCharacters, viewModel.PublishPlot); return(RedirectTo(project)); } catch { viewModel.OriginalName = project.ProjectName; return(View(viewModel)); } }
public ActionResult EditProject(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var projectToEdit = _data.Project.FindProjectById((int)id); if (projectToEdit == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var employees = _data.ApplicationUser.UsersPerDepartment(_data.ApplicationUser.FindUserByID(User.Identity.GetUserId()).Worker.DepartmentID); var roleId = _data.Role.FindRoleByName("Employee").Id; var f3 = _external.FillTheListOfDummiesForEdit(employees, roleId, projectToEdit); EditProjectViewModel f2 = new EditProjectViewModel() { Users = new List <DummyForProject>() }; f2.Project = projectToEdit; f2.Users = f3; return(View(f2)); }
private void OnProjectSelected(object sender, ItemSelectedEventArgs e) { var vm = new EditProjectViewModel(e.ItemId); Navigation.PushAsync(new EditProjectPage { BindingContext = vm }); }
public Init_DeliveryEnv_AllProperties_UI(Init_DeliveryEnv_AllProperties_API init_DeliveryEnv_AllProperties_API, EditProjectViewModel editProjectViewModel, EditProjectViewModelAsserts editProjectViewModelAsserts, EditProjectViewStateAsserts editProjectViewStateAsserts) { _init_DeliveryEnv_AllProperties_API = init_DeliveryEnv_AllProperties_API; _editProjectViewModel = editProjectViewModel; _editProjectViewModelAsserts = editProjectViewModelAsserts; _editProjectViewStateAsserts = editProjectViewStateAsserts; }
public async Task Create_New_Project_RedirectsToIndex() { var project = new EditProjectViewModel { Id = 2, Name = "Office 2", FromDuration = new DateTime(2020, 2, 10), ToDuration = new DateTime(2021, 5, 15) }; var result = await _controller.Create(project) as RedirectToActionResult; Assert.NotNull(result); Assert.AreEqual("Index", result.ActionName); }
/// <summary> /// Give the View Model that was Edited in View And I will do the necessary things to Update The Project /// </summary> /// <param name="f2"></param> public void EditProject(EditProjectViewModel f2) { var projectToEdit = _db.Projects.Find(f2.Project.ID); CheckIfAttachmentChanged(f2.Attach, projectToEdit); CheckChangesInEmployeesOfProject(projectToEdit, f2.Users); UpdateProjectProperties(projectToEdit, f2.Project); _db.Entry(projectToEdit).State = EntityState.Modified; _db.SaveChanges(); }
public ActionResult EditProject(EditProjectViewModel f2) { if (ModelState.IsValid && f2.Users.Count != 0) { _external.EditProject(f2); return(RedirectToAction("ViewAllProjects", "Display")); } return(View(f2)); }
public IActionResult Edit(int id) { var model = new EditProjectViewModel(); var dbproject = _hdDbContext.Projects.FirstOrDefault(t => t.Id == id); model.Id = dbproject.Id; model.ProjectName = dbproject.Name; model.Items = PopulateProjectByEdit(dbproject.Id); return(View(model)); }
public ProjectConfigValidation_DeliveryEnv_Valid_UI(ProjectConfigValidation_DeliveryEnv_Valid_API projectConfigValidation_DeliveryEnv_Valid_API, EditProjectViewModel editProjectViewModel, EditProjectViewModelAsserts editProjectViewModelAsserts, EditProjectViewStateAsserts editProjectViewStateAsserts) { _projectConfigValidation_DeliveryEnv_Valid_API = projectConfigValidation_DeliveryEnv_Valid_API; _editProjectViewModel = editProjectViewModel; _editProjectViewModelAsserts = editProjectViewModelAsserts; _editProjectViewStateAsserts = editProjectViewStateAsserts; }
public ActionResult Edit(EditProjectViewModel vm) { if (ModelState.IsValid) { Project updatedProj = Mapper.From(vm); updatedProj = projectRepo.Update(updatedProj); return(RedirectToAction("list")); } return(View(vm)); }
public Config_DeliveryEnv_UI(Config_DeliveryEnv_API config_DeliveryEnv_API, EditProjectViewModel editProjectViewModel, EditProjectViewModelAsserts editProjectViewModelAsserts, EditProjectViewStateAsserts editProjectViewStateAsserts) { _config_DeliveryEnv_API = config_DeliveryEnv_API; _editProjectViewModel = editProjectViewModel; _editProjectViewModelAsserts = editProjectViewModelAsserts; _editProjectViewStateAsserts = editProjectViewStateAsserts; }
public ChangeProjectId_UI(ChangeProjectId_API changeProjectId_API, EditProjectViewModel editProjectViewModel, EditProjectViewModelAsserts editProjectViewModelAsserts, EditProjectViewStateAsserts editProjectViewStateAsserts) { _changeProjectId_API = changeProjectId_API; _editProjectViewModel = editProjectViewModel; _editProjectViewModelAsserts = editProjectViewModelAsserts; _editProjectViewStateAsserts = editProjectViewStateAsserts; }
public async Task <IActionResult> Edit(EditProjectViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var viewModel = await this.projectService.EditAsync <EditProjectViewModel>(model); return(this.RedirectToAction("Details", "Project", new { name = model.Name, area = string.Empty })); }
private void ProjectEditStart(Project obj) { obj.ChangeTracker.ChangeTrackingEnabled = false; obj.Tasks = null; obj.ChangeTracker.ChangeTrackingEnabled = true; var projectEditViewModel = new EditProjectViewModel(obj, _dataService); var projectEditView = new EditProjectViewWindow(); projectEditView.ViewModel = (projectEditViewModel); projectEditView.Show(); }
public static EditProjectViewModel ProjectToEVM(this Project project) { EditProjectViewModel EditProjectVM = new EditProjectViewModel(); EditProjectVM.ShortDescription = project.ShortDescription.GetShortDescrtiption(130); EditProjectVM.NameProject = project.NameProject; EditProjectVM.EndDate = project.EndDate; EditProjectVM.NeedMoney = project.NeedMoney; EditProjectVM.ID = project.ID; return(EditProjectVM); }
public static EditProjectRequest ToRequest(this EditProjectViewModel vm, string userId) { return(new EditProjectRequest(userId) { Id = Identity.FromString(vm.Id), Description = vm.Description, DefinitionOfDone = vm.DefinitionOfDone, Name = vm.Name, TeamId = Identity.FromString(vm.SelectedTeamId), }); }
public EditProjectPage(Guid projectId) { BindingContext = new EditProjectViewModel(Application.Current as IApplication, projectId); InitializeComponent (); var save = new ToolbarItem (); save.Command = (BindingContext as EditProjectViewModel).Save; save.Text = "Save"; ToolbarItems.Add (save); }
public IActionResult EditProject(EditProjectViewModel model) { int result = ProjectService.EditProject(model); if (result == -1) { ViewBag.Message = "Project name already exists!"; return(View()); } CheckLoggedUser(); return(RedirectToAction("ViewCreatedProjects", "Project")); }
public IActionResult Edit(EditProjectViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } this.projects.Update(model.Id, model.Title, model.Description, model.Skills, model.ProjectCategories, model.Budget); this.TempData["SuccessMessage"] = "Project edited successfully. Go to \"My Projects\" to view your projects."; return(this.RedirectToAction(nameof(All))); }
public async Task <ActionResult> Edit(EditProjectViewModel project) { if (ModelState.IsValid) { await _projectService.Edit(project); return(RedirectToAction("Index", "Home")); } // project.Users = _projectService.GetProjectUsersAsSelectList(project.Id); return(View(project)); }
public async Task EditProject_WithNonExistingFireplace_ShouldThrowException() { // Arrange var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var groupRepository = new EfDeletableEntityRepository <Product_Group>(context); var productRepository = new EfDeletableEntityRepository <Product>(context); var projectRepository = new EfDeletableEntityRepository <Project>(context); var groupService = new GroupService(groupRepository); var prodcutService = new ProductService(productRepository, groupService); var cloudinaryService = new FakeCloudinary(); var projectService = new ProjectService(projectRepository, cloudinaryService, prodcutService, groupService); var user = new ApplicationUser { Id = "abc", FirstName = "Nikolay", LastName = "Doychev", Email = "*****@*****.**", EmailConfirmed = true, }; var fileName = "Img"; IFormFile file = new FormFile( new MemoryStream(Encoding.UTF8.GetBytes("This is a dummy file")), 0, 0, fileName, "dummy.png"); var project = new EditProjectViewModel { Id = "Test Id", Description = "Some description test 1", TypeProject = TypeProject.Classic.ToString(), TypeLocation = TypeLocation.Corner.ToString(), Name = "Проект 1", }; var seeder = new DbContextTestsSeeder(); await seeder.SeedUsersAsync(context); await seeder.SeedGroupAsync(context); await seeder.SeedProjectAsync(context); // Act AutoMapperConfig.RegisterMappings(typeof(EditProjectViewModel).Assembly); await Assert.ThrowsAsync <NullReferenceException>(() => projectService.EditAsync <EditProjectViewModel>(project)); }
public IActionResult Update(EditProjectViewModel model) { try { _validator.ValidateModelToUpdate(model); _logic.Update(model.WineProject); } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); } return(View(MVC.Views.Projects.EditProject)); }
public async Task <IActionResult> Edit(int id) { Project project = await _context.Projects.FirstOrDefaultAsync(u => u.ProjectId == id); if (project == null) { return(NotFound()); } EditProjectViewModel model = new EditProjectViewModel { Name = project.Name, Date = project.Date, Price = project.Price }; return(View(model)); }
// GET: Projects/Edit/5 // Pass in EditProjectViewModel, accessed from Edit View for Projects // Method accepts the ProjectId as an argument // View Model returns a list of videos associated with that ProjectId from the ProjectVideos Table public async Task <IActionResult> Edit(int id) { var user = await GetCurrentUserAsync(); EditProjectViewModel model = new EditProjectViewModel(_context, user, id); var project = await _context.Project.SingleOrDefaultAsync(m => m.ProjectId == id); if (project == null) { return(NotFound()); } return(View(model)); }
public DashboardController(ILogger <DashboardController> logger, IUserProfileService userProfileService, IProjectService projectService, IEducationsService educationService, IUserServicesService userServices) { _logger = logger; _profile = new AllUserProfileViewModel(); _singleUser = new UserProfileViewModel(); _userProfileService = userProfileService; _projectService = projectService; _educationService = educationService; _userService = userServices; _serviceViewModel = new ServiceViewModel(); _projectViewModel = new EditProjectViewModel(); _educationViewModel = new EducationViewModel(); }
public ActionResult EditProject(EditProjectModel model) { if (ModelState.IsValid) { Project project = db.Projects.Find(model.ProjectId); var projectMembers = new List <ApplicationUser>(); projectMembers.AddRange(db.Users.Where(u => model.MemberIds.Contains(u.Id))); project.Name = model.Name; project.Description = model.Description; project.ModifiedAt = DateTime.Now; project.TicketTag = model.TicketTag; project.IsActiveProject = model.IsActiveProject; project.ProjectManagerId = model.ProjectManagerId; project.ActiveWorkflowId = model.ActiveWorkflowId; project.Members.Clear(); foreach (string uId in model.MemberIds) { project.Members.Add(db.Users.Find(uId)); } db.SaveChanges(); return(RedirectToAction("Index")); } var projAdmins = new List <ApplicationUser>(); var availMembers = new List <ApplicationUser>(); foreach (ApplicationUser u in db.Users) { var roles = _permissionsHelper.ListUserRoles(u.Id); if (roles.Contains("SuperSolver") || roles.Contains("Solver") || roles.Contains("Reporter")) { availMembers.Add(u); } if (roles.Contains("ProjectAdmin")) { projAdmins.Add(u); } } var veiwModel = new EditProjectViewModel() { SelectedProject = db.Projects.Find(model.ProjectId), ProjectAdministrators = projAdmins, AvailableMembers = availMembers, Workflows = db.ProjectWorkflows.ToList() }; return(View(veiwModel)); }