public async Task <IActionResult> CreateProject([FromForm] [Bind("ProjectName", "ProjectClient", "ProjectDescription", "ProjectPlannedStart", "ProjectPlannedEnd")] AddProject model) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(User); model.ProjectCreatedByUser = user.UserName; var r = await _projectRepository.CreateProject(model); if (r != null) { ViewData["success"] = "Nytt prosjekt er opprettet."; return(RedirectToAction("ViewProject", new { id = r })); } else { ViewData["error"] = "Noe gikk galt. Prøv igjen. Om feilen vedvarer, kontakt teknisk support."; return(View(model)); } } else { TempData["error"] = "Feil med mottatt data. ModelStateInvalid!"; return(RedirectToAction("Index", null)); } }
public ActionResult Go(string title, string description, string scope, DateTime start, DateTime due) { AddProject project = new AddProject() { Title = title, Description = description, ScopeStatement = scope, StartDate = start, DueDate = due }; if (Session["username"] == null) { return(RedirectToAction("Index", "Home")); } if (project.Title == null || project.Description == null || project.ScopeStatement == null) { return(View(project)); } string userName = Session["username"].ToString(); DatabaseHelper db = new DatabaseHelper(); DataRow[] dr = db.RunSelectQuery($"SELECT role FROM [user] WHERE uname = '{userName}'"); if (!dr[0]["role"].ToString().Equals("Project Manager")) { return(RedirectToAction("Index", "Dashboard")); } db.RunInsertQuery($"INSERT INTO project (title, description, scopestatement, startdate, duedate, completionDate) VALUES ('{project.Title}', '{project.Description}','{project.ScopeStatement}','{project.StartDate}','{project.DueDate}', '01/01/0001')"); DataRow[] dr2 = db.RunSelectQuery($"SELECT projectid FROM project WHERE title = '{project.Title}'"); db.RunInsertQuery($"INSERT INTO user_project (uname, projectid) VALUES('{userName}','{dr2[0]["projectid"]}')"); return(Json(new { success = true, id = dr2[0]["projectid"] })); }
public void Can_Add_Project_With_Status_Active() { //Arrange var eventMock = new Mock <IEventBus>(); var mockRepository = new Mock <IProjectRepository>(); mockRepository.Setup(m => m.GetAll()).Returns(() => null); mockRepository.Setup(m => m.Add(It.IsAny <Project>())) .Callback((Project p) => mockRepository.Setup(m => m.GetAll()).Returns(new[] { p })); IAddProject service = new AddProject(mockRepository.Object, eventMock.Object); var newProject = new Project { Name = "newProject" }; var modelProject = new ProjectModel(newProject); //Act service.Invoke(modelProject); var allProjects = mockRepository.Object.GetAll(); var addedProject = allProjects.Last(); //Assert Assert.True(newProject.Name == addedProject.Name); Assert.True(allProjects.Count() == 1); Assert.True(addedProject.Status == ProjectStatus.Active); }
public ResponseMessage UpdateProject(AddProject project, int id) { ResponseMessage responseMessage = new ResponseMessage(); responseMessage = _projectRepository.UpdateProject(project, id); return(responseMessage); }
public ResponseMessage CreateProject(AddProject project) { try { if (_context.Project.Where(x => x.Name == project.Name && x.IsDelete == false).Count() > 0) { throw new ValueNotFoundException("Project Name already exist."); } int projCount = _context.Project.Count() + 1; string projCode = constantVal.ProjCodePrefix + projCount.ToString().PadLeft(6, '0'); ResponseMessage responseMessage = new ResponseMessage(); Project projectDB = _mapper.Map <Project> (project); projectDB.ProjCode = projCode; _context.Project.Add(projectDB); _context.SaveChanges(); //Add the site location // if (project.ProjectSiteLocationDetails.Any ()) { // foreach (var item in project.ProjectSiteLocationDetails) { // ProjectSitelocation projectSitelocation = new ProjectSitelocation (); // projectSitelocation.Name = item.Name; // projectSitelocation.ProjectId = projectDB.Id; // _context.ProjectSitelocation.Add (projectSitelocation); // } // } // _context.SaveChanges (); responseMessage.Message = "Project created sucessfully"; return(responseMessage); } catch (Exception ex) { throw ex; } }
public async Task AddProjectNotLogged() { var project = new AddProject { Title = "NewProject from API", Description = "Description for WebAPI", NewMembers = false, Technologies = new List <int> { 1, 7 } }; var json = JsonConvert.SerializeObject(project); var response = await httpClient.PostAsync(Configuration.WebApiUrl + "Projects", new StringContent(json, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { Assert.Fail("Should have no rights!"); } else { Assert.True(response.StatusCode == System.Net.HttpStatusCode.Unauthorized); } }
public ResponseMessage CreateProject(AddProject project) { ResponseMessage responseMessage = new ResponseMessage(); responseMessage = _projectRepository.CreateProject(project); return(responseMessage); }
public async Task AddProject() { await LoginAsync(); var project = new AddProject { Title = "NewProject from API", Description = "Description for WebAPI", NewMembers = false, Technologies = new List <int> { 1, 7 } }; var json = JsonConvert.SerializeObject(project); var response = await httpClient.PostAsync(Configuration.WebApiUrl + "Projects", new StringContent(json, Encoding.UTF8, "application/json")); if (response.IsSuccessStatusCode) { Assert.True(response.StatusCode == System.Net.HttpStatusCode.Created); var projectsList = await httpClient.GetAsync(Configuration.WebApiUrl + "Projects/"); var r = await projectsList.Content.ReadAsAsync <IEnumerable <Projects> >(); Assert.True(r.Count() == 7); } else { Assert.Fail("Non success Conection"); } }
public async Task <IActionResult> AddProject(AddProject model) { if (!ModelState.IsValid) { return(View(model)); } int userId = int.Parse(HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier)); Project project = new Project() { Name = model.Name, Description = model.Description, Status = model.Status }; var result = await _projectRepository.UserAddProject(userId, project); if (result == null) { // user id doesn't exist in database // this case won't happend unless something wrong with database as we get Id from user claims no chance for error return(View("~/Views/Project/UserNotFound.cshtml")); } return(RedirectToAction("Index", "Home")); }
private void EditProjectCommandExecute(Project project) { AddProjectVM dataContext = new AddProjectVM(changeCanAddProjectToTrue, logedUser, project); AddProject dialog = new AddProject(); dialog.DataContext = dataContext; dialog.Show(); }
private void tool_AddProject_Click(object sender, EventArgs e) { AddProject manage = new AddProject(this); this.Hide(); manage.StartPosition = FormStartPosition.CenterScreen; manage.Show(); }
public void showAddProject(Outlook.MailItem mailItem) { if (mailItem != null) { AddProject screen = new AddProject(); screen.ShowDialog(); } }
private void AddProjectCommandExecute() { CanAddProject = false; AddProjectVM dataContext = new AddProjectVM(changeCanAddProjectToTrue, logedUser); AddProject dialog = new AddProject(); dialog.DataContext = dataContext; dialog.Show(); }
public async Task <IActionResult> Post(AddProject command) { var result = await _bus.ExecuteAsync(command); await _bus.PublishAsync(new ProjectCreated { Id = result }); return(Created(result)); }
void Update() { if (AddProject == null) { AddProject = FindObjectOfType <AddProject> (); } if (OpenFileImage == null) { OpenFileImage = FindObjectOfType <TriLib.Samples.OpenFileImages> (); } }
private void AddProjectExecute() { try { AddProject addEmployee = new AddProject(); addEmployee.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void cmdNewProject_Click(object sender, EventArgs e) { AddProject ap = new AddProject(); ap.ShowDialog(); if (ap.NewProjectName.Trim() != "") { LoadProjects(); cbPartOfProject.Text = ap.NewProjectName; } }
private void Init() { var project = new AddProject { Name = "Name 3", Description = "Description 3" }; var response = PostAsync(_apiEndpoint, project).Result; response.StatusCode.Should().Be(HttpStatusCode.Created); }
private void AddBtn_Click(object sender, EventArgs e) { var AddProjectForm = new AddProject(); AddProjectForm.BoolRegisteredChanged += new EventHandler <BoolEvent>(AddProjectForm_BoolRegisteredChanged); AddProjectForm.ShowDialog(); AddProjectForm.BoolRegisteredChanged -= AddProjectForm_BoolRegisteredChanged; AddProjectForm.Dispose(); AddProjectForm = null; }
public async Task Project_Should_Be_Created() { var addProject = new AddProject { Name = "title 1", Description = "Description 1" }; var response = await PostAsync(_apiEndpoint, addProject); response.StatusCode.Should().Be(HttpStatusCode.Created); var createdProject = response.GetObject <Guid>(); createdProject.Should().NotBe(Guid.Empty); }
public void addingProject(string tablename, string projecttitle, string description, string uname1, string name1, string uname2, string name2, string uname3, string name3) { AddProject ap = new AddProject(); int rows = ap.checkProject(projecttitle); if (rows == 0) { ap.projectAdd(projecttitle, description, uname1, name1, uname2, name2, uname3, name3); ap.createProjectTable(tablename); } else { MessageBox.Show("Project Already Exists!!!"); } }
public JsonResult AddedProjectDetails(AddProject prtdetails) { try { AddProjectResponse result = null; if (prtdetails != null) { result = CABusinessProjectTrackingAPIClient.GetHttpResponse <AddProjectResponse>(prtdetails, CABPTMethodConstants.ADDNEWPROJECT); } return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { JsonExceptionResult jsonexc = new JsonExceptionResult(); return(Json(JsonConvert.SerializeObject(new CABPTException(ex, out jsonexc)))); } }
public async Task Project_should_be_deleted() { var project = new AddProject { Name = "Name 3", Description = "Description 3" }; var response = await PostAsync(_apiEndpoint, project); response.StatusCode.Should().Be(HttpStatusCode.Created); var projectId = response.GetObject <Guid>(); var deleteCommand = new DeleteProject(projectId); var deleteResponse = await DeleteAsync($"{_apiEndpoint}/{deleteCommand.Id}"); deleteResponse.StatusCode.Should().Be(HttpStatusCode.NoContent); }
public IActionResult Update(AddProject project, int id) { try { var response = _projectService.UpdateProject(project, id); return(Ok(new { message = response.Message, code = 204 })); } catch (ValueNotFoundException e) { Util.LogError(e); return(StatusCode(StatusCodes.Status422UnprocessableEntity, new ErrorClass() { code = StatusCodes.Status422UnprocessableEntity.ToString(), message = e.Message })); } catch (Exception e) { Util.LogError(e); return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorClass() { code = StatusCodes.Status500InternalServerError.ToString(), message = "Something went wrong" })); } }
/////////////// ////////////// /////////////// Project ////////////// /////////////// ////////////// public async Task <string> CreateProject(AddProject project) { Project p = new Project { }; p.ProjectName = project.ProjectName; p.ProjectClient = project.ProjectClient; p.ProjectDescription = project.ProjectDescription; p.ProjectPlannedStart = project.ProjectPlannedStart; p.ProjectPlannedEnd = project.ProjectPlannedEnd; p.ProjectCreatedByUser = project.ProjectCreatedByUser; p.ProjectRegistered = DateTime.Now; p.Unique_ProjectIdString = getGuid(); ProjectCycle initCycle = new ProjectCycle { CycleName = "Mine Oppgaver", CycleRegistered = DateTime.Now, Unique_CycleIdString = getGuid(), CycleNumber = 1, CyclePlannedStart = project.ProjectPlannedStart, CyclePlannedEnd = project.ProjectPlannedEnd, CycleDescription = "Du kan opprette alle oppgaver under denne syklusen, eller du kan lage flere sykluser. Hver syklus kan ha mange arbeidsoppgaver." }; List <ProjectCycle> initList = new List <ProjectCycle>(); initList.Add(initCycle); p.ProjectCycles = initList; p.NumberOfProjectCycles = initList.Count; _db.Project.Add(p); if (await _db.SaveChangesAsync() > 0) { return(p.Unique_ProjectIdString); } else { return(null); } }
public async Task <ActionResult> AddOrDeleteProject(AddProject model) { if (model.isDelete) { var project = await _services.GetFirstProject(model.Status, model.URL); if (project != null) { await _services.DeleteProject(project); return(Redirect("/")); } return(NotFound()); } var NewProject = new Projects { Status = model.Status, Url = model.URL }; await _services.AddProject(NewProject); return(Redirect("/")); }
//------------------------------------------------------------------------- void OnGUI() { if (!AddingProject) { if (CurrentProject != null) { EditorGUILayout.BeginHorizontal(); int select_index = 0; if (!MapProjectIndexCombineWithSelectIndex.TryGetValue(CurrentProject.ProjectIndex, out select_index)) { return; } select_index = MapProjectIndexCombineWithSelectIndex[CurrentProject.ProjectIndex]; select_index = EditorGUILayout.Popup("当前项目:", select_index, ArrayProjectBundleIdentity); if (CurrentSelectIndex != select_index) { _decideCurrentProject(select_index); CurrentSelectIndex = select_index; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("当前项目公司名:", CurrentProject.CompanyName); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("当前项目名:", CurrentProject.AppName); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("当前项目BundleIdentify:", CurrentProject.BundleIdentify); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); bool click_delete_project = GUILayout.Button("删除选中项目信息", GUILayout.Width(200)); if (click_delete_project) { _deleteProject(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("==================华丽的分割线=================="); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); bool click_add_project = GUILayout.Button("添加项目信息", GUILayout.Width(200)); if (click_add_project) { AddProject = new _InitProjectInfo(); AddProject.IsDefault = ListInitProjectInfo.Count == 0 ? true : false; AddingProject = true; } EditorGUILayout.EndHorizontal(); } else { _drowAddProjectWindow(); EditorGUILayout.BeginHorizontal(); bool click_add_project = GUILayout.Button("确定", GUILayout.Width(200)); if (click_add_project) { int add_projectindex = 0; if (ListInitProjectInfo.Count != 0) { add_projectindex = ListInitProjectInfo[ListInitProjectInfo.Count - 1].ProjectIndex + 1; } AddProject.ProjectIndex = add_projectindex; if (AddProject != null && AddProject.isAllInit()) { _addProject(); } } EditorGUILayout.EndHorizontal(); } }
private void OpenFormAddProject(object arg) { var addProject = new AddProject(); addProject.Show(); }
public ResponseMessage UpdateProject(AddProject project, int id) { ResponseMessage responseMessage = new ResponseMessage(); try { var projectDB = _context.Project.Where(x => x.Id == id && x.IsDelete == false).FirstOrDefault(); if (projectDB != null) { if (_context.Project.Where(x => x.Name == project.Name && x.Id != id && x.IsDelete == false).Count() > 0) { throw new ValueNotFoundException("Project Name already exist."); } else { projectDB.Name = project.Name; projectDB.Area = project.Area; projectDB.IcId = project.ICId; projectDB.BuId = project.BUId; projectDB.EdrcCode = project.EDRCCode; projectDB.JobCode = project.JobCode; projectDB.CreatedBy = 1; //TODO projectDB.CreatedAt = DateTime.Now; projectDB.UpdatedBy = 1; //TODO projectDB.UpdatedAt = DateTime.Now; projectDB.IsActive = project.IsActive; var projectLocations = _context.ProjectSitelocation.Where(x => x.ProjectId == project.Id).ToList(); var addedSiteLocations = project.ProjectSiteLocationDetails.Where(x => !projectLocations.Any(p => p.Id == x.Id)).ToList(); var deletedSiteLocations = projectLocations.Where(x => !project.ProjectSiteLocationDetails.Any(p => p.Id == x.Id)).ToList(); var updatedSiteLocations = project.ProjectSiteLocationDetails.Where(x => projectLocations.Any(p => p.Id == x.Id)).ToList(); //add Project site Location if (addedSiteLocations.Any()) { foreach (var item in addedSiteLocations) { ProjectSitelocation projectSitelocation = new ProjectSitelocation(); projectSitelocation.Name = item.Name; projectSitelocation.ProjectId = id; _context.ProjectSitelocation.Add(projectSitelocation); } } //delete Project site Location if (deletedSiteLocations.Any()) { foreach (var item in deletedSiteLocations) { _context.ProjectSitelocation.Remove(item); } } //update Project site Location if (updatedSiteLocations.Any()) { foreach (var item in updatedSiteLocations) { ProjectSitelocation projectSitelocation = _context.ProjectSitelocation.Where(x => x.Id == item.Id).FirstOrDefault(); projectSitelocation.Name = item.Name; } } _context.SaveChanges(); AuditLogs audit = new AuditLogs() { Action = "Project", Message = string.Format("Project Updated Successfully {0}", project.Name), CreatedAt = DateTime.Now, CreatedBy = 1 //TODO }; _commonRepo.AuditLog(audit); return(responseMessage = new ResponseMessage() { Message = "Project updated successfully.", }); } } else { throw new ValueNotFoundException("Project not available."); } } catch (Exception ex) { throw ex; } }
public async Task <IHttpActionResult> Get([FromBody] AddProject dto) { var resp = await _imageService.AddProjectAsync(dto); return(Ok(resp)); }