public ActionResult NewContactPerson(int bankId, int?contactPersonId) { if (contactPersonId != null) { ContactPersonService contactPersonService = new ContactPersonService(); contactPersonService.Remove(contactPersonService.Set().Single(s => s.ID == contactPersonId)); contactPersonService.Commit(); return(RedirectToAction("NewContactPerson", new { bankId, contactPersonId = (int?)null })); } BankService bankService = new BankService(); ViewModelItem viewModelItem = new ViewModelItem(); PositionService positionService = new PositionService(); viewModelItem.BankModel = (BankModel)bankService.Set().Single(s => s.ID == bankId); viewModelItem.PositionModels = positionService.Set().Select(s => (PositionModel)s).ToList(); var list = bankService.Set().Single(s => s.ID == bankId).ContactPersons; viewModelItem.ContactPersonModels = bankService.Set().Single(s => s.ID == bankId).ContactPersons.Where(w => w.Position.Name != "General Director").Select(a => (ContactPersonModel)a).ToList(); return(View(viewModelItem)); }
public ActionResult Edit(ViewModelItem viewModelItem, DateTime BirthDate) { BankService bankService = new BankService(); Bank bank = bankService.Set().Single(s => s.ID == viewModelItem.BankModel.ID); bank.Name = viewModelItem.BankModel.Name; bank.URL = viewModelItem.BankModel.URL; bankService.Commit(); viewModelItem.ContactPersonModel.DateOfBirth = BirthDate; ContactPersonService contactPersonService = new ContactPersonService(); ContactPerson contactPerson = contactPersonService.Set().Single(s => s.ID == viewModelItem.ContactPersonModel.ID); contactPerson.FirstName = viewModelItem.ContactPersonModel.FirstName; contactPerson.LastName = viewModelItem.ContactPersonModel.LastName; contactPerson.DateOfBirth = viewModelItem.ContactPersonModel.DateOfBirth; contactPersonService.Commit(); viewModelItem.FromPost = true; return(View(viewModelItem)); }