Esempio n. 1
0
        public PartialViewResult EditPeople(ProjectPrimaryKey projectPrimaryKey)
        {
            var project   = projectPrimaryKey.EntityObject;
            var viewModel = new EditPeopleViewModel(project.ProjectPeople.OrderBy(x => x.Person.FullNameFirstLast).ToList());

            return(ViewEditPeople(viewModel, project));
        }
Esempio n. 2
0
 public ViewResult Edit(int id)
 {
     People people = _people.GetPeople(id);
     EditPeopleViewModel editPeopleViewModel = new EditPeopleViewModel
     {
         Id = people.Id,
         Name = people.Name,
         Email = people.Email,
         Department = people.Department,
         ExistingPhotoPath = people.PhotoPath
     };
     return View(editPeopleViewModel);
 }
Esempio n. 3
0
        public EditPeopleViewModel GetPeopleForEdit(int id)
        {
            var people = base.GetById(id);
            var image  = _imageService.GetByCenterId(id);
            var vm     = new EditPeopleViewModel
            {
                FirstName   = people.Firstname,
                LastName    = people.Lastname,
                Description = people.Description,
                ImageName   = image.ImageName
            };

            return(vm);
        }
Esempio n. 4
0
        private PartialViewResult ViewEditPeople(EditPeopleViewModel viewModel, Project project)
        {
            var allPeople = HttpRequestStorage.DatabaseEntities.People.GetActivePeople();

            if (!allPeople.Contains(CurrentPerson))
            {
                allPeople.Add(CurrentPerson);
            }

            var allRelationshipTypes = ProjectPersonRelationshipType.All;

            var viewData = new EditPeopleViewData(allPeople, allRelationshipTypes, CurrentPerson);

            return(RazorPartialView <EditPeople, EditPeopleViewData, EditPeopleViewModel>(viewData, viewModel));
        }
Esempio n. 5
0
        public People Save(EditPeopleViewModel model)
        {
            var people = new People
            {
                Id           = model.Id,
                Firstname    = model.FirstName,
                Lastname     = model.LastName,
                Description  = model.Description,
                CenterTypeId = (int)CenterTypes.People,
                UniqueId     = new Guid()
            };
            var savedPeople = base.AddOrUpdate(people);

            return(savedPeople);
        }
Esempio n. 6
0
        public ActionResult EditPeople(ProjectPrimaryKey projectPrimaryKey, EditPeopleViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditPeople(viewModel, project));
            }

            HttpRequestStorage.DatabaseEntities.ProjectPeople.Load();
            var projectPeople = HttpRequestStorage.DatabaseEntities.ProjectPeople.Local;

            viewModel.UpdateModel(project, projectPeople);
            HttpRequestStorage.DatabaseEntities.SaveChanges();

            return(new ModalDialogFormJsonResult());
        }
Esempio n. 7
0
        public async Task <IActionResult> Save(EditPeopleViewModel model, IFormFile PeopleImage)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(nameof(Edit), model));
            }

            var savedPeople = _peopleService.Save(model);

            if (PeopleImage != null)
            {
                var image = _imageService.GetByCenterId(savedPeople.Id) ?? new Image {
                    CenterId = savedPeople.Id
                };

                var imageName = await ImageHelper.SaveImage(PeopleImage, 200, 200, true);

                image.ImageName = imageName;
                _imageService.AddOrUpdate(image);
            }
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 8
0
        public IActionResult Edit(EditPeopleViewModel model)
        //public RedirectToActionResult Create(People people)
        {
            if (ModelState.IsValid)
            {
                // Retrieve the employee being edited from the database
                People people = _people.GetPeople(model.Id);
                // Update the employee object with the data in the model object
                people.Name = model.Name;
                people.Email = model.Email;
                people.Department = model.Department;

                if (model.Photos != null && model.Photos.Count > 0)
                {
                    // If a new photo is uploaded, the existing photo must be
                    // deleted. So check if there is an existing photo and delete
                    if (model.ExistingPhotoPath != null)
                    {
                        string filePath = Path.Combine(hostingEnvironment.WebRootPath,
                            "images", model.ExistingPhotoPath);
                        System.IO.File.Delete(filePath);
                    }
                    // Save the new photo in wwwroot/images folder and update
                    // PhotoPath property of the employee object which will be
                    // eventually saved in the database
                    
                    people.PhotoPath = ProcessUploadedFile(model);
                }
               




                _people.UpdatePeople(people);
                return RedirectToAction("Index", new { id = people.Id });
            }
            return View();

        }