public void ExampleSubsequentChapterAnnouncement_OnlySingleChapterBooksIncluded_ReturnsNull() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.IIJN, TestProject.TestBook.IIIJN); var model = new ProjectSettingsViewModel(testProject); Assert.IsNull(model.ExampleSubsequentChapterAnnouncement); }
public void ChapterAnnouncementIsStrictlyNumeric_OnlySingleChapterBooksIncluded_ReturnsFalse() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.IIJN, TestProject.TestBook.IIIJN); var model = new ProjectSettingsViewModel(testProject); Assert.IsFalse(model.ChapterAnnouncementIsStrictlyNumeric); }
public ActionResult SaveSettings(ProjectSettingsViewModel model) { if (!ModelState.IsValid) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(PartialView("SettingsProject", model)); } string userId = User.Identity.GetUserId(); var result = projectService.SaveProjectSettings(userId, model); if (result == GenericServiceResult.AccessDenied) { Response.StatusCode = (int)HttpStatusCode.Forbidden; return(RedirectToAction("Forbidden", "Error")); } if (result == GenericServiceResult.Error) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(RedirectToAction("BadRequest", "Error")); } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
private void Settings_Click(object sender, EventArgs e) { var origCursor = Cursor; Cursor = Cursors.WaitCursor; var model = new ProjectSettingsViewModel(m_project); using (var dlg = new ProjectSettingsDlg(model)) { var result = dlg.ShowDialog(this); Cursor = origCursor; if (result != DialogResult.OK) { return; } m_project.UpdateSettings(model); SaveCurrentProject(); if (dlg.UpdatedBundle != null) { Analytics.Track("UpdateProjectFromBundleData", new Dictionary <string, string> { { "language", m_project.LanguageIsoCode }, { "ID", m_project.Id }, { "recordingProjectName", m_project.Name }, { "bundlePathChanged", (m_project.OriginalBundlePath != model.BundlePath).ToString() } }); var project = m_project.UpdateProjectFromBundleData(dlg.UpdatedBundle); project.OriginalBundlePath = model.BundlePath; SetProject(project); } } UpdateDisplayOfProjectInfo(); }
public void ChapterAnnouncementIsStrictlyNumeric_ChapterNumberWithNoLabel_ReturnsTrue() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.GAL, TestProject.TestBook.IJN); var model = new ProjectSettingsViewModel(testProject); model.ChapterAnnouncementStyle = ChapterAnnouncement.ChapterLabel; Assert.IsTrue(model.ChapterAnnouncementIsStrictlyNumeric); }
public void ExampleSingleChapterAnnouncement_SkipOptionTrue_ReturnsEmptyString() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.IJN, TestProject.TestBook.IIIJN); var model = new ProjectSettingsViewModel(testProject); model.SkipChapterAnnouncementForSingleChapterBooks = true; Assert.IsEmpty(model.ExampleSingleChapterAnnouncement); }
public void ChapterAnnouncementIsStrictlyNumeric_PageHeader_ReturnsFalse() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.GAL, TestProject.TestBook.IJN); var model = new ProjectSettingsViewModel(testProject); model.ChapterAnnouncementStyle = ChapterAnnouncement.PageHeader; Assert.IsFalse(model.ChapterAnnouncementIsStrictlyNumeric); }
public SaveProjectCommand(IGameStateService gameStateService, IFilePicker filePicker, IWindowProvider windowProvider, ProjectSettingsViewModel projectSettingsViewModel) { _gameStateService = gameStateService; _filePicker = filePicker; _windowProvider = windowProvider; _projectSettingsViewModel = projectSettingsViewModel; _gameStateService.OnGameCreated += _gameStateService_OnGameCreated; _gameStateService.OnGameChanged += _gameStateService_OnGameChanged; }
public void ExampleSingleChapterAnnouncement_OnlyMultipleChapterBooksIncluded_ReturnsNull() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.GAL, TestProject.TestBook.IJN); var model = new ProjectSettingsViewModel(testProject); model.SkipChapterAnnouncementForFirstChapter = false; model.SkipChapterAnnouncementForSingleChapterBooks = false; Assert.IsNull(model.ExampleSingleChapterAnnouncement); }
public void ExampleFirstChapterAnnouncement_MultiChapterBookIncluded_ExampleBasedOnChapterOneOfFirstBookWithMultipleChapters() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.IJN, TestProject.TestBook.IIIJN); var model = new ProjectSettingsViewModel(testProject); model.SkipChapterAnnouncementForFirstChapter = false; Assert.AreEqual("1 JON 1", model.ExampleFirstChapterAnnouncement); model.ChapterAnnouncementStyle = ChapterAnnouncement.ChapterLabel; Assert.AreEqual("1", model.ExampleFirstChapterAnnouncement); }
public async Task <ActionResult> ProjectSettings(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var entity = await db.Projects.FindAsync(id); if (entity == null) { return(RedirectToAction("Index")); } var projSettings = new ProjectSettingsViewModel { Name = entity.Name, Id = entity.Id, Description = entity.Description, }; projSettings.ProjectPriorities = await db.ProjectPriorities.OrderBy(y => y.PriorityValue).Where(x => x.ProjectId == id).Select(x => new ProjectPriorityModel { Field = x.Field, PriorityValue = x.PriorityValue, ProjectPriorityDetails = x.ProjectPriorityDetails.Select(z => new ProjectPriorityDetailModel { FieldValue = z.FieldValue, FieldPriorityValue = z.FieldPriorityValue } ).OrderBy(z => z.FieldPriorityValue).ToList(), Id = x.Id, ProjectId = x.ProjectId } ).ToListAsync(); if (projSettings.ProjectPriorities.Count <= 0) { projSettings.ProjectPriorities.Add(new ProjectPriorityModel { Field = "Title", PriorityValue = 1, ProjectPriorityDetails = new List <ProjectPriorityDetailModel>() }); projSettings.ProjectPriorities.Add(new ProjectPriorityModel { Field = "Company", PriorityValue = 2, ProjectPriorityDetails = new List <ProjectPriorityDetailModel>() }); projSettings.ProjectPriorities.Add(new ProjectPriorityModel { Field = "SIC", PriorityValue = 3, ProjectPriorityDetails = new List <ProjectPriorityDetailModel>() }); } return(View(projSettings)); }
public void ExampleSubsequentChapterAnnouncement_MultiChapterBookIncluded_ExampleBasedOnChapterTwoOfFirstBookWithMultipleChapters() { var testProject = TestProject.CreateTestProject(TestProject.TestBook.IJN, TestProject.TestBook.IIIJN); var model = new ProjectSettingsViewModel(testProject); Assert.AreEqual("1 JON 2", model.ExampleSubsequentChapterAnnouncement); Assert.IsFalse(model.ChapterAnnouncementIsStrictlyNumeric); model.ChapterAnnouncementStyle = ChapterAnnouncement.ChapterLabel; Assert.AreEqual("2", model.ExampleSubsequentChapterAnnouncement); Assert.IsTrue(model.ChapterAnnouncementIsStrictlyNumeric); }
private ProjectSettingsViewModel GetProjectSettingsViewModel(Project project) { ProjectSettingsViewModel projectSettingsViewModel = this._mapper.Map <ProjectSettingsViewModel>(project); projectSettingsViewModel.UserAccesses = new List <UserAccessViewModel>(); foreach (var item in project.ProjectsUsers) { projectSettingsViewModel.UserAccesses.Add(this._mapper.Map <UserAccessViewModel>(item)); } return(projectSettingsViewModel); }
private void ShowProjectScriptPresenterDlg(Func <ProjectExporter, Form> getProjectScriptPresenterDlg) { EnsureGroupsAreInSynchWithCharactersInUse(); var model = new ProjectSettingsViewModel(m_project); while (m_project.ReferenceText == null) { string msg; using (var dlg = new ProjectSettingsDlg(model)) { var msgFmt = LocalizationManager.GetString("Project.UnavailableReferenceText", "This project uses the {0} reference text, which is no longer available. " + "If possible, put the required reference text files in" + "\r\n {1}\r\n" + "and then click Retry to use the {0} reference text.\r\n" + "Otherwise, to continue and temporarily use the English reference text, click Ignore.\r\n" + "Note: to permanently change the reference text used by this project, open the {2} " + "dialog box and select the desired reference text on the {3} tab page."); msg = String.Format(msgFmt, m_project.UiReferenceTextName, m_project.ReferenceTextIdentifier.ProjectFolder, dlg.Text, dlg.ReferenceTextTabPageName); } switch (MessageBox.Show(msg, Program.kProduct, MessageBoxButtons.AbortRetryIgnore)) { case DialogResult.Abort: return; case DialogResult.Ignore: m_project.ReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English); break; } } var exporter = new ProjectExporter(m_project); if (!IsOkToExport(exporter)) { return; } using (var dlg = getProjectScriptPresenterDlg(exporter)) { ShowModalDialogWithWaitCursor(dlg); ShowLastLocation(); } }
private void OpenConfiguration() { try { DataContext = new ProjectSettingsViewModel(project); } catch (Exception ex) { var msg = $"There was an error during the opening of project's configuration:\n{ex.Message}\nDo you want to create a new configuration?"; if (Helpers.ShowMessageBoxError(msg, askConfirm: true) ?? false == false) { Close(); } else { NewConfiguration(); } } }
public GenericServiceResult SaveProjectSettings(string userId, ProjectSettingsViewModel model) { try { int projectId = model.Id; bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(GenericServiceResult.AccessDenied); } Project project = unitOfWork.Projects.Get(projectId); string projectTitleBeforeChanging = project.Title; ProjectSettings projectSettings = unitOfWork.ProjectSettings.Get(projectId); project.Title = model.Title; project.About = model.About; projectSettings.AccessToChangeProject = (int)model.AccessToChangeProject; projectSettings.AccessToCreateBoard = (int)model.AccessToCreateBoard; projectSettings.AccessToDeleteBoard = (int)model.AccessToDeleteBoard; unitOfWork.ProjectSettings.Update(projectSettings); unitOfWork.Projects.Update(project); string creatorId = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.ProjectId == projectId && p.Role == (int)ProjectRoles.Administrator).UserId; NotificationMessage message = new NotificationMessage { Title = $"{projectTitleBeforeChanging}", Message = "Project settings were updated.", Link = null, ObjectId = projectId, Initiator = userId, SendTo = creatorId }; Notifyer.Notify(message); return(GenericServiceResult.Success); } catch { return(GenericServiceResult.Error); } }
public OperationResult <ProjectSettingsViewModel> GetProjectSettings(string userId, int projectId, int page = 0, string searchFilter = "") { try { bool canUserChangeProject = CanUserChangeProject(userId, projectId); if (!canUserChangeProject) { return(new OperationResult <ProjectSettingsViewModel> { Model = null, Message = GenericServiceResult.AccessDenied }); } Project project = unitOfWork.Projects.Get(projectId); ProjectSettings projectSettings = unitOfWork.ProjectSettings.Get(projectId); List <ProjectUser> projectUsers = unitOfWork.ProjectUser.Get(p => p.ProjectId == projectId).ToList(); List <User> users = (from u in unitOfWork.Users.Query() join r in projectUsers on u.Id equals r.UserId where u.UserName.Contains(searchFilter) select u ).Skip(page * 15).Take(15).ToList(); int rowsCount = projectUsers.Count; List <UserInfo> userInfos = new List <UserInfo>(); foreach (var user in users) { UserProfile profile = unitOfWork.ClientManager.GetProfile(user.Id); int userRole = unitOfWork.ProjectUser.GetFirstOrDefaultWhere(p => p.UserId == user.Id && p.ProjectId == projectId).Role; bool isUserAdministrator = (ProjectRoles)userRole == ProjectRoles.Administrator; bool canYouDeleteUser = isUserAdministrator || userId == user.Id; UserInfo userInfo = new UserInfo { Id = user.Id, Email = user.Email, Icon = profile.Icon, Name = profile.Name, CanYouDeleteUser = !canYouDeleteUser }; userInfos.Add(userInfo); } ProjectUsersViewModel projectUsersModel = new ProjectUsersViewModel { ProjectUsers = userInfos, CurrentPage = page, PageSize = 15, RowsCount = rowsCount }; projectUsersModel.GetPages(); bool canUserDeleteProject = CanUserDeleteProject(userId, projectId); ProjectSettingsViewModel model = new ProjectSettingsViewModel { Id = projectId, Title = project.Title, About = project.About, AccessToChangeProject = (ProjectSettingsRole)projectSettings.AccessToChangeProject, AccessToCreateBoard = (BoardSettingsRole)projectSettings.AccessToCreateBoard, AccessToDeleteBoard = (BoardSettingsRole)projectSettings.AccessToDeleteBoard, ProjectUsersViewModel = projectUsersModel, CanUserDeleteProject = canUserDeleteProject }; return(new OperationResult <ProjectSettingsViewModel> { Model = model, Message = GenericServiceResult.Success }); } catch { return(new OperationResult <ProjectSettingsViewModel> { Model = null, Message = GenericServiceResult.Error }); } }
public MainViewModel(ProjectSettingsViewModel projectSettingsVm, ProjectManagementViewModel projectManagementVm, MetadataViewModel metadataVm) { ProjectSettingsVm = projectSettingsVm; ProjectManagementVm = projectManagementVm; MetadataVm = metadataVm; }
public ProjectSettings() { InitializeComponent(); vm = new ProjectSettingsViewModel(); DataContext = vm; }
public async Task <JsonResult> ProjectSettings(ProjectSettingsViewModel model) { if (model == null) { return(Json("Error")); } bool error = false; using (DbContextTransaction dbTran = db.Database.BeginTransaction()) { try { if (model.ProjectPriorities != null) { db.ProjectPriorityDetails.RemoveRange(db.ProjectPriorityDetails.Where(x => x.ProjectPriority.ProjectId == model.Id)); db.ProjectPriorities.RemoveRange(db.ProjectPriorities.Where(x => x.ProjectId == model.Id)); var projectPriorities = model.ProjectPriorities.Select(c => new ProjectPriority { ProjectId = model.Id, Field = c.Field, PriorityValue = c.PriorityValue, CreationDate = DateTime.Now, LastUpdate = DateTime.Now, }).ToList(); var savedEntities = db.ProjectPriorities.AddRange(projectPriorities); await db.SaveChangesAsync(); if (model.ProjectPriorityDetails != null) { db.ProjectPriorityDetails.AddRange(model.ProjectPriorityDetails.Select(c => new ProjectPriorityDetail { ProjectPriorityId = savedEntities.Where(x => x.Field.Equals(c.Type)).FirstOrDefault().Id, FieldValue = c.FieldValue.Equals("Blank") ? string.Empty : c.FieldValue, FieldPriorityValue = c.FieldPriorityValue, CreationDate = DateTime.Now, LastUpdate = DateTime.Now, }).AsEnumerable()); } await db.SaveChangesAsync(); dbTran.Commit(); } } catch (Exception ex) { dbTran.Rollback(); error = true; } } if (error) { return(Json("Error")); } else { return(Json("Ok")); } }