예제 #1
0
        public ActionResult Create()
        {
            CreateProjectViewModel createProjectViewModel = new CreateProjectViewModel();

            createProjectViewModel.ObjectState = ObjectState.Added;
            return(View(createProjectViewModel));
        }
예제 #2
0
        public ActionResult Edit(int?id, CreateProjectViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            Project project;

            if (!id.HasValue)
            {
                project = new Project();
                DbContext.Projects.Add(project);
            }
            else
            {
                project = DbContext.Projects.FirstOrDefault(p => p.Id == id && p.Archive == false);

                if (project == null)
                {
                    return(RedirectToAction(nameof(ProjectController.ViewProject)));
                }
            }

            project.Name    = model.Name;
            project.Updated = DateTime.Now;

            DbContext.SaveChanges();

            return(RedirectToAction(nameof(ProjectController.ViewProject)));
        }
        public CreateProject()
        {
            InitializeComponent();

            model = new CreateProjectViewModel();
            DataContext = model;
        }
        public ActionResult Create(CreateProjectViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var project = Mapper.Map <CreateProjectViewModel, Project>(model);

            switch (model.ConnectionType)
            {
            case ConnectionTypes.Ip:
                project.ConnectionSettings = new IpConnectionSettings();

                var newIpProjectId = _projectService.Add(project, User.Identity.GetUserId());

                return(RedirectToAction("CreateIpProject", new { projectId = newIpProjectId }));

            case ConnectionTypes.Com:
                project.ConnectionSettings = new IpConnectionSettings();

                var newComProjectId = _projectService.Add(project, User.Identity.GetUserId());

                return(RedirectToAction("CreateComProject", new { projectId = newComProjectId }));
            }

            return(View(model));
        }
예제 #5
0
        public ActionResult New()
        {
            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);
                }
            }

            CreateProjectViewModel viewModel = new CreateProjectViewModel()
            {
                ProjectAdministrators = projAdmins.OrderBy(u => u.FullNameStandard).ToList(),
                AvailableMembers      = availMembers.OrderBy(u => u.FullNameStandard).ToList(),
                Workflows             = db.ProjectWorkflows.ToList()
            };

            return(View(viewModel));
        }
예제 #6
0
        public ActionResult ProjectCreator(int?id, CreateProjectViewModel form)
        {
            if (ModelState.IsValid)
            {
                Project project = new Project();

                if (id.HasValue)
                {
                    project = Db.Projects.FirstOrDefault(p => p.Id == id);
                    if (project == null)
                    {
                        return(RedirectToAction(nameof(ProjectController.Index)));
                    }
                    project.DateUpdated = DateTime.Now;
                }
                else
                {
                    Db.Projects.Add(project);
                }

                project.Name        = form.Name;
                project.Description = form.Description;
            }
            Db.SaveChanges();
            return(RedirectToAction(nameof(ProjectController.Index)));
        }
예제 #7
0
        public async Task <IActionResult> Create(CreateProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                var teams = model.Teams.Select(c => _context.Teams.FirstOrDefault(u => u.ID == c)).ToList();

                var project = new Project
                {
                    Teams       = teams,
                    ProjectName = model.ProjectName,
                    Description = model.Description
                };

                _context.Add(project);
                await _context.SaveChangesAsync();

                var projectTeams = teams.Select(c => new ProjectTeams
                {
                    ProjectID = project.ID,
                    TeamID    = c.ID
                });

                _context.AddRange(projectTeams);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
예제 #8
0
        public IActionResult Create()
        {
            var viewModel = new CreateProjectViewModel();

            viewModel.TagSelectListItems = _context.Tags.ToList();
            return(View(viewModel));
        }
예제 #9
0
        public IActionResult Create(CreateProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (!employeeDataService.Exists(model.ProjectManagerNick))
                {
                    ModelState.AddModelError("ProjectManagerNick", "Project Manager Nick is not valid");

                    return(View(model));
                }

                var companyId = userManager.GetUserAsync(this.User).Result.CompanyId;


                var project = new ProjectServiceModel
                {
                    Name           = model.Name,
                    Description    = model.Description,
                    StartDate      = model.StartDate,
                    EndDate        = model.EndDate,
                    CompanyId      = companyId,
                    ProjectManager = employeeDataService.FindByNickname(model.ProjectManagerNick)
                };

                projectDataService.Create(project);

                return(RedirectToAction("AllProjects", "Project"));
            }

            return(View(model));
        }
예제 #10
0
        /// <summary>
        /// Adds a project by current user username to the Db. Adds a default empty index file to the Db.
        /// Adds current user as owner of the new project to the Db.
        /// </summary>
        /// <param name="model">'CreateProjectViewModel'</param>
        /// <param name="ownerName">Owner Name</param>
        public void addProject(CreateProjectViewModel model, string ownerName)
        {
            Project newProject = new Project();

            newProject._projectName       = model._projectName;
            newProject._projectFileTypeId = model._projectTypeId;

            _db._projects.Add(newProject);
            _db.SaveChanges();

            string extension    = _db._fileTypes.Where(x => x.ID == model._projectTypeId).SingleOrDefault()._extension;
            string aceExtension = _db._fileTypes.Where(x => x.ID == model._projectTypeId).SingleOrDefault()._aceExtension;
            string defaultData  = _db._fileTypes.Where(x => x.ID == model._projectTypeId).SingleOrDefault()._initialCode;

            ProjectFile defaultFile = new ProjectFile();

            defaultFile._projectFileName = "index" + "." + extension;
            defaultFile._projectFileType = "." + extension;
            defaultFile._aceExtension    = aceExtension;
            defaultFile._projectFileData = defaultData;
            defaultFile._projectID       = _db._projects.OrderByDescending(p => p.ID)
                                           .Select(p => p.ID).FirstOrDefault();

            _db._projectFiles.Add(defaultFile);
            _db.SaveChanges();

            ProjectOwner owner = new ProjectOwner();

            owner._projectID = defaultFile._projectID;
            owner._userName  = ownerName;

            _db._projectOwners.Add(owner);
            _db.SaveChanges();
        }
예제 #11
0
        public IActionResult Create(CreateProjectViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Items = PopulateGroup();
                return(View(model));
            }
            if (IsProjectNameExists(model.ProjectName) == false)
            {
                ModelState.AddModelError(string.Empty, "项目的名称已经存在");
            }
            if (ModelState.ErrorCount > 0)
            {
                model.Items = PopulateGroup();
                return(View(model));
            }
            var dbProject = new DD.Electricity.Cloud.Domain.Entities.Headquarter.Project();

            dbProject.Name    = model.ProjectName;
            dbProject.GroupId = int.Parse(model.GroupId);

            _hdDbContext.Projects.Add(dbProject);
            _hdDbContext.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
예제 #12
0
        public async Task <IActionResult> CreateByContractId(CreateProjectViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _mainRepository.CreateAsync(new Project
                {
                    Id                         = Guid.NewGuid(),
                    Name                       = model.Name,
                    CreateTime                 = DateTime.Now.Date,
                    EnterProgress              = (int)model.EnterProgress,
                    EnterDate                  = model.EnterDate,
                    SiteProgress               = (int)model.SiteProgress,
                    SiteFinishedDate           = model.SiteFinishedDate,
                    ExitDate                   = model.ExitDate,
                    ReportProgress             = (int)model.ReportProgress,
                    ProjectProgressExplanation = model.ProjectProgressExplanation,
                    ContractId                 = model.ContractId,
                    BridgeId                   = model.BridgeId
                });

                TempData["globalMessage"] = "成功创建:" + model.Name + "";
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(View());
        }
예제 #13
0
        public async Task <IActionResult> Create(CreateProjectViewModel createViewModel)
        {
            if (ModelState.IsValid)
            {
                //Create new project object to add.
                Project project = new Project()
                {
                    Name         = createViewModel.Name,
                    Description  = createViewModel.Description,
                    UserProjects = new List <UserProject>(),
                };
                //From posted email list, get emails that exist in db, then return a new UserProject object list (EqualityComparer is not used here).
                var toaddlist = createViewModel.Members
                                .Where(email => UserExists(email))
                                .Select(email => new UserProject()
                {
                    Project = project,
                    User    = _context.Users.FirstOrDefault(u => u.Email.Equals(email)),
                });

                project.UserProjects.AddRange(toaddlist);
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = project.Id }));
            }
            return(View(createViewModel));
        }
        public async Task <bool> CreateProject(CreateProjectViewModel model)
        {
            var Project = new CosmosProjectDto()
            {
                Id          = Guid.NewGuid().ToString(),
                ProjectName = model.Name,
                ProjectLogo = null,
                Mark        = 0,
                Developer   = new List <Developer>()
                {
                },
                Evalution = 0,
                Framework = new Framework()
                {
                },
                ProjectPath = null,
                SuperVisior = new SuperVisor()
                {
                },
                Wiki = null
            };
            var result = await _NoDb.AddAsync(Project);

            return(result.IsSuccess);
        }
예제 #15
0
        public ActionResult CreateNewProject()
        {
            CreateProjectViewModel model = new CreateProjectViewModel();

            model._projectType = _projectFileService.populateDropdownData();
            return(View(model));
        }
        public IActionResult CreateProject(CreateProjectViewModel vm)
        {
            if (!_auth.Authorise(RolesEnum.Admin, _context)) // Check logged in
            {
                return(Redirect("~/Project/Dashboard"));
            }

            // Create a new project and fill in fields
            var newProj = new Projects();

            newProj.BookingNumber      = vm.ProjectNumber;
            newProj.MaximumMinutes     = vm.MaxHours * 60;
            newProj.CurrentUsedMinutes = 0;
            newProj.Locked             = false;
            newProj.ProjectDescription = vm.ProjectDesc;
            newProj.ProjectName        = vm.ProjectName;

            // Add project to database
            _context.Projects.Add(newProj);
            // Save database
            _context.SaveChanges();

            // Kick out to user management
            return(Redirect("~/UserManagement/ManageUsers"));
        }
예제 #17
0
        public ActionResult CreateNewProject(FormCollection collection)
        {
            if (!ModelState.IsValid)
            {
                CreateProjectViewModel viewModel = new CreateProjectViewModel();
                viewModel._projectName = collection["_projectName"];
                return(View("CreateNewProject", viewModel));
            }
            else
            {
                CreateProjectViewModel model = new CreateProjectViewModel();
                model._projectName   = collection["_projectName"];
                model._projectTypeId = Int32.Parse(collection["radioChoice"]);

                if (_projectService.createNewProjectIsValid(model._projectName, User.Identity.Name))
                {
                    _projectService.addProject(model, User.Identity.Name);
                    return(RedirectToAction("Index", "Overview"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "This project already exists.");
                    return(View("CreateNewProject"));
                }
            }
        }
예제 #18
0
        public async Task <IActionResult> CreateProject(CreateProjectViewModel model)
        {
            var     team    = _context.Teams.SingleOrDefault(t => t.Name == model.Team.Name);
            Project project = new Project
            {
                Title       = model.Title,
                Description = model.Description,
                Team        = team
            };

            //save to database
            _context.Add(project);

            await _context.SaveChangesAsync();

            int Id = project.Id;

            ProjectDetails details = new ProjectDetails()
            {
                Id          = project.Id,
                Title       = project.Title,
                Description = project.Description,
                Tasks       = project.Tasks
            };


            //go to details view
            return(View("DetailsProjectView", details));
        }
예제 #19
0
        public void TestProjectExistsForUser()
        {
            var projectVM1 = new CreateProjectViewModel
            {
                Name    = "project1",
                OwnerID = "1"
            };
            var projectVM2 = new CreateProjectViewModel
            {
                Name    = "project2",
                OwnerID = "1"
            };
            var projectVM3 = new CreateProjectViewModel
            {
                Name    = "project3",
                OwnerID = "1"
            };

            var result1 = pservice.ProjectExistsForUser(projectVM1);
            var result2 = pservice.ProjectExistsForUser(projectVM2);
            var result3 = pservice.ProjectExistsForUser(projectVM3);

            Assert.IsTrue(result1);
            Assert.IsFalse(result2);
            Assert.IsTrue(result3);
        }
예제 #20
0
        public async Task <ActionResult> CreateProject(CreateProjectViewModel model)
        {
            var Project = new ProjectModel {
                ProjectName = model.ProjectName
            };

            try {
                Ctx.Projects.Add(Project);
                var result = await Ctx.SaveChangesAsync();

                if (result > 0)
                {
                    ModelState.Clear();
                    var ErrorMessageSuccess = "Projektet " + model.ProjectName + " har skapats";
                    return(View(new CreateProjectViewModel {
                        ErrorMessage = ErrorMessageSuccess
                    }));
                }
            }
            catch {
                var ErrorMessageFail = "Skapandet av projektet: " + model.ProjectName + " misslyckades.";
                return(View(new CreateProjectViewModel {
                    ErrorMessage = ErrorMessageFail
                }));
            }
            return(View());
        }
예제 #21
0
        public ActionResult Create()
        {
            CreateProjectViewModel model = new CreateProjectViewModel();

            if (Session["workersList"] is null)
            {
                UserManager.Users.ToList().ForEach(x => {
                    model.Workers.Add(new ApplicationUserViewModel
                    {
                        Id        = x.Id,
                        Name      = x.UserName,
                        Image     = null,
                        InProject = false
                    });
                });

                Session.Add("workersList", model.Workers);
            }
            else
            {
                model.Workers = (List <ApplicationUserViewModel>)Session["workersList"];
            }

            model.Workers = model.Workers.OrderBy(x => x.InProject == false).ToList();

            return(View(model));
        }
예제 #22
0
 protected override void OnInitialized()
 {
     Project = new CreateProjectViewModel()
     {
         Name = string.Empty
     };
 }
예제 #23
0
        public ActionResult Create()
        {
            CreateProjectViewModel model = new CreateProjectViewModel();

            model.CreateProjectsDisabled = !this.userService.CanUserCreateProject();
            return(this.View(model));
        }
예제 #24
0
        public IActionResult Create(CreateProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                Project project = new Project
                {
                    Title       = model.Title,
                    Description = model.Description,
                    GitUrl      = model.GitUrl
                };
                var savedProject = _project.AddProject(project);

                if (savedProject != null)
                {
                    StudentProject studentProject = new StudentProject
                    {
                        StudentId = model.StudentId,
                        ProjectId = savedProject.ProjectId
                    };

                    _project.AddStudentProject(studentProject);

                    return(RedirectToAction("Index"));
                }
            }
            return(View(model));
        }
예제 #25
0
        public IActionResult CreateProject()
        {
            CreateProjectViewModel model = new CreateProjectViewModel {
            };

            return(View(model));
        }
예제 #26
0
        public IActionResult Create(CreateProjectViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var presenter = _presenterFactory.Create(MessageHandler, ErrorHandler);
            var request   = vm.ToRequest(CurrentUserId);

            try
            {
                var uc       = _useCaseFactory.Create;
                var response = uc.Execute(request);
                presenter.Present(response);
                return(RedirectToAction(nameof(Index), new { id = response.Id.ToPresentationIdentity() }));
            }
            catch (InvalidRequestException ire)
            {
                presenter.PresentErrors(ire.Message, ire.Errors);
                return(View(presenter.Present(vm)));
            }
            catch (Exception e)
            {
                presenter.PresentMessage(MessageType.Error, e.Message);
                return(View(presenter.Present(vm)));
            }
        }
예제 #27
0
        public GenericServiceResult CreateNewProject(string userId, CreateProjectViewModel model)
        {
            try
            {
                ProjectSettings projectSettings = new ProjectSettings
                {
                    AccessToChangeProject = (int)model.AccessToChangeProject,
                    AccessToDeleteBoard   = (int)model.AccessToDeleteBoard,
                    AccessToCreateBoard   = (int)model.AccessToCreateBoard
                };

                Project project = new Project {
                    Title = model.Title, About = model.About, Settings = projectSettings
                };
                User user = unitOfWork.UserManager.Users.FirstOrDefault(x => x.Id == userId);

                ProjectUser projectUser = new ProjectUser {
                    Project = project, Role = (int)ProjectRoles.Administrator, User = user
                };
                unitOfWork.ProjectUser.Create(projectUser);

                return(GenericServiceResult.Success);
            }

            catch
            {
                return(GenericServiceResult.Error);
            }
        }
예제 #28
0
        public IActionResult Create(CreateProjectViewModel viewModel)
        {
            HttpContextAccessor accessor = new HttpContextAccessor();

            var claims = accessor.HttpContext.User.Claims;
            int userId = -1;

            foreach (var claim in claims)
            {
                string claimValue = claim.Value;
                int.TryParse(claimValue, out userId);
            }

            var model = new CreateProjectModel(viewModel.Name, viewModel.Description, userId);

            try
            {
                _projectService.Create(model);
            }
            catch (Exception e)
            {
                viewModel.ErrorMessage = e.Message;
                return(View(nameof(Create), viewModel));
            }

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
예제 #29
0
        public async Task <ActionResult> Create(CreateProjectViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                var owner  = await db.Users.FirstAsync(u => u.Id == userId);

                var projectType = await db.ProjectTypes.FindAsync(model.TypeID);

                var project = new Project()
                {
                    Name         = model.Name,
                    ProjectType  = projectType,
                    CreationDate = DateTime.Now,
                    Owner        = owner
                };

                db.Projects.Add(project);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectTypes = db.ProjectTypes.ToList();
            return(View(model));
        }
        public async Task <IActionResult> Create([FromForm, Bind("Name,Description,ManagerId")] CreateProjectViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var readManagerUserRequest = new ReadUsersRequest
                {
                    Roles = new List <string> {
                        "manager"
                    }
                };
                var managers = await _userApplicationService.Handle(readManagerUserRequest);

                model.Managers = managers
                                 .Select(manager => new SelectListItem
                {
                    Value = manager.Id.ToString(),
                    Text  = manager.FullName
                })
                                 .ToList();

                return(View(model));
            }

            var createProjectRequest = new CreateProjectRequest
            {
                Name          = model.Name,
                Description   = model.Description,
                ManagerUserId = model.ManagerId.Value
            };
            var response = await _projectApplicationService.Handle(createProjectRequest);

            return(RedirectToAction(nameof(Index)));
        }
예제 #31
0
        public ActionResult CreateProject(CreateProjectViewModel model, List <string> userIds)
        {
            var users = GetAllUsers();

            var members = new List <ApplicationUser>();

            if (userIds == null)
            {
                userIds = new List <string>();
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            foreach (var id in userIds)
            {
                members.Add(users.FirstOrDefault(u => u.Id == id));
            }

            var newProject = new Project()
            {
                Name    = model.Name,
                Details = model.Details,
                Users   = members,
                Active  = true
            };

            DbContext.Projects.Add(newProject);
            DbContext.SaveChanges();

            return(RedirectToAction(nameof(BugController.ViewAllProjects), "Bug"));
        }