public ActionResult DonationDonorEntityPeopleSelect() { DonorEntityPersonDonationViewModel personDonation = new DonorEntityPersonDonationViewModel(); ///PersonPrimaryInfo[] personInfo = unitOfWork.PersonPrimaryInfoRepository.Get().ToArray(); personDonation.People = unitOfWork.PersonPrimaryInfoRepository.PeopleMultiSelectList(); return View(personDonation); }
public ActionResult DonationDonorEntityTitleSelect(DonorEntityPersonDonationViewModel personDonation) { ICollection<SelectListItem> selectedPeople = personDonation.People.Where(x => x.Selected).ToList(); personDonation.People = selectedPeople; personDonation.Active = true; personDonation.Title = selectedPeople.First().Text; return View(personDonation); }
public ActionResult DonationDonorEntityPeopleCreate(DonorEntityPersonDonationViewModel personDonation) { DonationDonorEntity newDonorEntity = new DonationDonorEntity(); newDonorEntity.Title = DonorEntityTitle(personDonation); newDonorEntity.Active = personDonation.Active; int[] selectedPersonPrimaryInfoIDs = personDonation.People.Select(x => Convert.ToInt32(x.Value)).ToArray<int>(); newDonorEntity.PersonPrimaryInfoes = unitOfWork.PersonPrimaryInfoRepository.Get(x => selectedPersonPrimaryInfoIDs.Contains(x.PersonPrimaryInfoID)).ToArray(); unitOfWork.DonationDonorEntityRepository.Insert(newDonorEntity); unitOfWork.Save(); return RedirectToAction("Index"); }
public string DonorEntityTitle(DonorEntityPersonDonationViewModel personDonation) { string title = ""; if (String.IsNullOrWhiteSpace(personDonation.Title)) { title = String.Join(" & ", personDonation.People.Select(x => new String(x.Text.Take(100).ToArray<char>())).ToArray<string>()); } else { title = personDonation.Title; } return new String(title.Trim().Take(200).ToArray()); }