Exemplo n.º 1
0
        public IHttpActionResult EditProject(int id)
        {
            Project proj = Serviceproj.GetById(id);

            Models.ProjectViewModel project = new Models.ProjectViewModel();
            project.description    = proj.description;
            project.duration       = proj.duration;
            project.endDay         = proj.endDay;
            project.startDay       = proj.startDay;
            project.numberResource = proj.numberResource;

            return(Ok(project));
        }
Exemplo n.º 2
0
        public async Task Join_Specific_Project_Collaborator_Should_Collaborate(string projectName, string userName)
        {
            var service = new ProjectService();
            var project = new Models.ProjectViewModel {
                Name = projectName
            };
            var collaborator = new UserCollaborator(new Microsoft.AspNetCore.Identity.IdentityUser {
                NormalizedUserName = userName
            });

            await service.Add(project);

            await service.Join(project.Name, collaborator);

            project.Collaborators.Should().Contain(collaborator);
            collaborator.CollaboratedProjects.Should().Contain(project);
        }
Exemplo n.º 3
0
        public ActionResult Create(ProjectViewModel project)
        {
            var user      = _userManager.FindById(User.Identity.GetUserId());
            var myUser    = db.Users.Where(x => x.AspNetUsersId.Equals(user.Id)).FirstOrDefault();
            var dbProject = new Project()
            {
                CategoryId        = project.SelectedCategoryId,
                CreatorId         = myUser.Id,
                DateInserted      = DateTime.Now,
                CurrentFundAmount = project.Project.CurrentFundAmount,
                Description       = project.Project.Description,
                Ratio             = project.Project.Ratio,
                StatusId          = project.Project.StatusId,
                DueDate           = project.Project.DueDate,
                TargetAmount      = project.Project.TargetAmount,
                Title             = project.Project.Title
            };

            //project.CreatorId = myUser.Id;
            //project.StatusId = 1;
            //project.DateInserted = DateTime.Now;

            if (ModelState.IsValid)
            {
                db.Projects.Add(dbProject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var viewModel = new Models.ProjectViewModel()
            {
                Categories = db.Categories.ToList(),
                Statuses   = db.ProjectStatus.ToList(),
                Project    = dbProject
            };


            //ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", project.CategoryId);
            //ViewBag.StatusId = new SelectList(db.ProjectStatus, "Id", "Name", project.StatusId);

            return(View(viewModel));
        }
Exemplo n.º 4
0
        public List <ProjectViewModel> Afficher(int id)
        {
            List <Models.ProjectViewModel> list1 = new List <Models.ProjectViewModel>();

            Models.ProjectViewModel pro = null;
            return(Serviceproj.GetAll().Where(s => s.isApprouve == true).Where(s => s.userId == id).Select(s => new ProjectViewModel()
            {
                projectId = s.projectId,
                numberResource = s.numberResource,
                userId = s.userId,
                description = s.description,
                price = s.price,
                duration = s.duration,
                endDay = s.endDay,
                state = s.state,
                startDay = s.startDay,
                prixRetard = s.prixRetard * s.nbJrsProlongation,
                isApprouve = s.isApprouve,
                nbJrsProlongation = s.nbJrsProlongation
            }).ToList());
        }
Exemplo n.º 5
0
        public ActionResult Create(ProjectViewModel model, HttpPostedFileBase upload)
        {
            var     user      = _userManager.FindById(User.Identity.GetUserId());
            var     myUser    = db.Users.Where(x => x.AspNetUsersId.Equals(user.Id)).FirstOrDefault();
            Project dbProject = null;
            var     imageFile = _uploadFileManager.UploadFile(upload);

            if (ModelState.IsValid)
            {
                dbProject = new Project()
                {
                    CategoryId        = model.SelectedCategoryId,
                    CreatorId         = myUser.Id,
                    DateInserted      = DateTime.Now,
                    CurrentFundAmount = model.Project.CurrentFundAmount,
                    Description       = model.Project.Description,
                    Ratio             = model.Project.Ratio,
                    StatusId          = 1,
                    DueDate           = model.Project.DueDate,
                    TargetAmount      = model.Project.TargetAmount,
                    Title             = model.Project.Title,
                    PhotoUrl          = imageFile != null ? imageFile.FileName : null,
                    Image             = imageFile != null ? imageFile.Content : null
                };
                dbProject = db.Projects.Add(dbProject);
                db.SaveChanges();
                return(RedirectToAction("Edit", new { id = dbProject.Id }));
            }
            var viewModel = new Models.ProjectViewModel()
            {
                Categories = db.Categories.ToList(),
                Statuses   = db.ProjectStatus.ToList(),
                Project    = dbProject,
                MyProjects = CreatorProjects(myUser.Id)
            };

            return(View(viewModel));
        }