public async Task <ActionResult> Activate(string contactKey) { if (String.IsNullOrEmpty(contactKey)) { return(HttpNotFound()); } var database = contactKey.Split('|')[0]; var dataareaid = contactKey.Split('|')[1]; var contactid = contactKey.Split('|')[2]; var contact = (await db.GetCustomerContacts(ActiveCustomer)) .Where(x => x.DatabaseName == database && x.DataAreaId == dataareaid && x.ContactPersonId == contactid).FirstOrDefault(); if (contact == null) { return(HttpNotFound()); } var model = new EditContactViewModel(); model.contactPerson = contact; model.roles = (await db.GetRiwalRoles()).Where(x => x.DatabaseName == ActiveCustomer.DatabaseName && x.CompanyId == ActiveCustomer.CompanyId); return(View(model)); }
// GET: Contacts/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var contact = await _contactsRepository.GetContactsByIdAsync(id); if (contact == null) { return(NotFound()); } ViewData["PersonId"] = new SelectList(await _peopleRepository.GetPeopleAsync(), "Id", "Nome", contact.PersonId); var vm = new EditContactViewModel { Id = contact.Id, PersonId = contact.PersonId, Type = contact.Type, Value = contact.Value }; return(View(vm)); }
public async Task <ActionResult> Deactivate(EditContactViewModel model) { if (ModelState.IsValid) { var contact = (await db.GetCustomerContacts(ActiveCustomer)) .Where(x => x.ContactPersonKey == model.contactPerson.ContactPersonKey && x.Activated == true).FirstOrDefault(); if (contact == null) { return(HttpNotFound()); } var userStore = new UserStore(); var userCompanies = (await userStore.GetCompaniesAsync(contact.UserId)); userCompanies = userCompanies.Where(x => x.CustomerKey != ActiveCustomer.CustomerKey); var result = await userStore.UpdateCompaniesByIdAsync(contact.UserId, userCompanies); if (result) { ViewBag.Message = String.Format(Resources.UserDeactivatedMessage, contact.FullName, contact.Email); ViewBag.Message2 = ""; return(View("Completed")); } } ViewBag.Message = Resources.ErrorUserNotActivatedMessage; ViewBag.Message2 = ""; return(View("Completed")); }
public async Task <ActionResult <ContactViewModel> > EditContact([FromBody] EditContactViewModel model) { if (!ModelState.IsValid) { NotifyModelStateErrors(); return(ModelStateErrorResponseError()); } var editContactCommand = _mapper.Map <EditContactCommand>(model); var result = await Mediator.SendCommandAsync(editContactCommand); if (result.Success) { await Mediator.NotifyDomainNotification( DomainNotification.Success($" The contact to {model.ContactName} was edited with success !")); } var contact = await _contactRepository.GetContactById(model.ContactId); var returnModel = _mapper.Map <ContactViewModel>(contact); return(ResponsePost( nameof(EditContact), returnModel)); }
/* * Route user to page to edit their account details */ public ActionResult Edit() { // Get logged in user string email = User.Identity.GetUserName(); Contact contact = _contactService.GetContactByEmail(email); if (contact == null) { return(HttpNotFound()); } ViewBag.States = PopulateStatesDropdown(); EditContactViewModel model = new EditContactViewModel { ContactId = contact.ContactId, Username = contact.Username, FirstName = contact.FirstName, LastName = contact.LastName, Email = contact.Email, PhoneNumber = contact.PhoneNumber, Address1 = contact.Address1, Address2 = contact.Address2, City = contact.City, State = contact.State, ZipCode = contact.ZipCode, HasPublicProfile = contact.HasPublicProfile }; return(View(model)); }
public ActionResult AddContact(EditContactViewModel viewModel) { if (!ModelState.IsValid) { return(ViewAddContact(viewModel, null)); } var person = new Person(viewModel.FirstName, Role.Unassigned.RoleID, DateTime.Now, true, false) { LastName = viewModel.LastName, PersonAddress = viewModel.Address, Email = viewModel.Email, Phone = viewModel.Phone, OrganizationID = viewModel.OrganizationID, AddedByPersonID = CurrentPerson.PersonID }; HttpRequestStorage.DatabaseEntities.People.Add(person); EditContactViewModel.SetAuthenticatorsForGivenEmailAddress(viewModel, person); HttpRequestStorage.DatabaseEntities.SaveChanges(); SetMessageForDisplay($"Successfully added {person.GetFullNameFirstLastAsUrl()}"); return(new ModalDialogFormJsonResult()); }
public async Task <IActionResult> PutContact(int id, EditContactViewModel contact) { if (id != contact.Id) { return(BadRequest()); } //_context.Entry(contact).State = EntityState.Modified; try { Contact c = new Contact { Id = contact.Id, PersonId = contact.PersonId, Type = contact.Type, Value = contact.Value }; await _contactsRepository.UpdateContactsAsync(c); } catch (DbUpdateConcurrencyException) { if (!ContactExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult EditContact(PersonPrimaryKey personPrimaryKey) { var person = personPrimaryKey.EntityObject; var viewModel = new EditContactViewModel(person); return(ViewAddContact(viewModel, person)); }
public void AreAllRowsSavedTest_PassNoAddresses_ShouldReturnTrue() { EditContactViewModel vm = new EditContactViewModel(null, null); var result = vm.AreAllRowsSaved(); Assert.IsTrue(result); }
public async Task <ActionResult> Importer(Guid id) { var importer = await mediator.SendAsync(new GetImporterByNotificationId(id)); var model = new EditContactViewModel(importer); return(View(model)); }
private static ImporterData GetNewImporterData(EditContactViewModel model, ImporterData oldImporterData) { var newImporterData = new ImporterData { Contact = GetNewContactData(model, oldImporterData.Contact), Business = GetNewBusinessInfoData(model, oldImporterData.Business) }; return(newImporterData); }
private PartialViewResult ViewAddContact(EditContactViewModel viewModel, Person person) { var organizations = HttpRequestStorage.DatabaseEntities.Organizations.OrderBy(x => x.OrganizationName) .ToSelectListWithEmptyFirstRow(x => x.OrganizationID.ToString(CultureInfo.InvariantCulture), x => x.DisplayName.ToString(CultureInfo.InvariantCulture), "No Organization"); bool fullUpUser = person != null && person.IsFullUser(); var viewData = new EditContactViewData(organizations, fullUpUser); return(RazorPartialView <EditContact, EditContactViewData, EditContactViewModel>(viewData, viewModel)); }
public virtual ActionResult Edit(EditContactViewModel model) { Contact contact; try { // Determine if this is a new contact or not if (model.Id == 0) { contact = new CreateContactCommand(_serviceFactory).WithCompanyId(model.Company.Id) .SetAssistant(model.Assistant) .SetDirectPhone(model.DirectPhone) .SetEmail(model.Email) .SetExtension(model.Extension) .SetMobilePhone(model.MobilePhone) .SetName(model.Name) .SetNotes(model.Notes) .SetTitle(model.Title) .SetReferredBy(model.ReferredBy) .RequestedByUserId(CurrentUserId) .Execute(); } else { contact = new EditContactCommand(_serviceFactory).WithContactId(model.Id) .SetAssistant(model.Assistant) .SetDirectPhone(model.DirectPhone) .SetEmail(model.Email) .SetExtension(model.Extension) .SetMobilePhone(model.MobilePhone) .SetName(model.Name) .SetNotes(model.Notes) .SetTitle(model.Title) .SetReferredBy(model.ReferredBy) .RequestedByUserId(CurrentUserId) .Execute(); } return(RedirectToAction(MVC.Contact.Details(contact.Id))); } catch (ValidationException ex) { foreach (var error in ex.Errors) { ModelState.AddModelError(error.PropertyName, error.ErrorMessage); } // Retrieve the company from the database for the sidebar model.Company = new CompanySummaryViewModel(new CompanyByIdQuery(_unitOfWork, _companyAuthProcess).WithCompanyId(model.Company.Id).Execute()); return(View(model)); } }
private static Contact GetNewContactData(EditContactViewModel model, Contact oldContactData) { var newContactData = new Contact { Email = model.Email, Name = model.FullName, TelephonePrefix = model.TelephonePrefix, Telephone = model.Telephone }; return(newContactData); }
private static BusinessInfoData GetNewBusinessInfoData(EditContactViewModel model, BusinessInfoData oldBusinessInfoData) { var newBusinessInfoData = new BusinessInfoData { Name = model.Name, AdditionalRegistrationNumber = oldBusinessInfoData.AdditionalRegistrationNumber, BusinessType = oldBusinessInfoData.BusinessType, OtherDescription = oldBusinessInfoData.OtherDescription, RegistrationNumber = oldBusinessInfoData.RegistrationNumber }; return(newBusinessInfoData); }
private static ContactData GetNewContactData(EditContactViewModel model, ContactData oldContactData) { var newContactData = new ContactData { Email = model.Email, FullName = model.FullName, TelephonePrefix = model.TelephonePrefix, Telephone = model.Telephone, FaxPrefix = oldContactData.FaxPrefix, Fax = oldContactData.Fax }; return(newContactData); }
public virtual ActionResult Edit(int id) { var contact = new ContactByIdQuery(_unitOfWork, _contactAuthProcess).RequestedByUserId(CurrentUserId).WithContactId(id).Execute(); if (contact == null) { ViewBag.EntityType = "Contact"; return(View(MVC.Shared.Views.EntityNotFound)); } var model = new EditContactViewModel(contact); return(View(model)); }
public ActionResult EditContact(PersonPrimaryKey personPrimaryKey, EditContactViewModel viewModel) { var person = personPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewAddContact(viewModel, person)); } viewModel.UpdateModel(person); SetMessageForDisplay($"Successfully updated {person.GetFullNameFirstLastAsUrl()}"); return(new ModalDialogFormJsonResult()); }
public static EditContactViewModel ConvertToViewModel(this ContactDto contact) { var returnVM = new EditContactViewModel { EMail = contact.EMail ?? "N/A", FirstName = contact.FirstName ?? "N/A", LastName = contact.LastName ?? "N/A", TelephoneNumber_Entry = contact.TelephoneNumber_Entry ?? "N/A", Created = contact.CreatedUtc.LocalDateTime, CreatedBy = contact.CreatedBy ?? "N/A", Modified = contact.ModifiedUtc?.LocalDateTime, ModifiedBy = contact.ModifiedBy ?? "N/A" }; return(returnVM); }
public virtual ActionResult Add(int companyId) { var company = new CompanyByIdQuery(_unitOfWork, _companyAuthProcess).WithCompanyId(companyId) .RequestedByUserId(CurrentUserId) .Execute(); if (company == null) { ViewBag.EntityType = "Company"; return(View(MVC.Shared.Views.EntityNotFound)); } var model = new EditContactViewModel(company); return(View(MVC.Contact.Views.Edit, model)); }
public async Task <ActionResult> Delete(EditContactViewModel model) { if (ModelState.IsValid) { var contact = (await db.GetCustomerContacts(ActiveCustomer)) .Where(x => x.ContactPersonKey == model.contactPerson.ContactPersonKey).FirstOrDefault(); if (contact == null) { return(HttpNotFound()); } String emailAddress; if (ROLWeb.Helpers.AppGlobal.IsProduction) { if (this.ActiveCustomer.CompanyId == "15" || this.ActiveCustomer.CompanyId == "16") { emailAddress = await new ROLWeb.Models.Rentals.RentalsDAL().GetOnRentEmailAddress(this.ActiveCustomer); } else { emailAddress = (new OverviewDAL().GetRiwalCompany(this.ActiveCustomer.DatabaseName, this.ActiveCustomer.CompanyId)).AdministrationEmail; } } else { emailAddress = ((System.Security.Claims.ClaimsIdentity)User.Identity).FindFirst("Email").Value; } if (MailClient.SendDeleteUserEmail( this.ActiveCustomer, contact, ((System.Security.Claims.ClaimsIdentity)User.Identity).FindFirst("FullName").Value, emailAddress)) { ViewBag.Message = String.Format(Resources.RequestSentMessage); ViewBag.Message2 = ""; return(View("Completed")); } } ViewBag.Message = Resources.ErrorRequestNotSentMessage; ViewBag.Message2 = ""; return(View("Completed")); }
public ActionResult Edit(EditContactViewModel model) { if (this.ModelState.IsValid) { Contact dbContact = new Contact { Id = model.Id, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, Description = model.Description }; this.contacts.Edit(dbContact); this.TempData["SuccessMsg"] = "Contact is updated!"; return(this.RedirectToAction("Index", "Home")); } return(this.View(model)); }
public void AreAllRowsSavedTest_Pass2ValidAddresses_ShouldReturnTrue() { EditContactViewModel vm = new EditContactViewModel(null, null) { Addresses = new ObservableCollection <Address>() { new Address { Street = "a", City = "s", State = "d", PostalCode = "d" }, new Address { Street = "a", City = "s", State = "d", PostalCode = "d" }, } }; var result = vm.AreAllRowsSaved(); Assert.IsTrue(result); }
public async Task <ActionResult> Importer(Guid id, EditContactViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var importer = await mediator.SendAsync(new GetImporterByImportNotificationId(id)); var newImporterData = new Importer { Contact = GetNewContactData(model, importer.Contact), Name = model.Name, }; await mediator.SendAsync(new SetImporterDetailsForImportNotification(id, newImporterData)); return(RedirectToAction("Index", "Home")); }
public ActionResult Edit(int id) { Contact dbContact = contacts.GetById(id); if (dbContact == null) { return(this.HttpNotFound()); } EditContactViewModel model = new EditContactViewModel { Id = dbContact.Id, FirstName = dbContact.FirstName, LastName = dbContact.LastName, PhoneNumber = dbContact.PhoneNumber, Description = dbContact.Description }; return(View(model)); }
public async Task <ActionResult> Importer(Guid id, EditContactViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var importer = await mediator.SendAsync(new GetImporterByNotificationId(id)); var importerData = GetNewImporterData(model, importer); await mediator.SendAsync(new SetImporterDetails(id, importerData)); await this.auditService.AddAuditEntry(this.mediator, id, User.GetUserId(), NotificationAuditType.Updated, NotificationAuditScreenType.Importer); return(RedirectToAction("Index", "Overview")); }
public IActionResult EditContact(Guid id, EditContactViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var updatedContact = _contactService.Edit(id, model); if (updatedContact is null) { return(NotFound($"Ops. Contato com Id: '{id}' não foi encontrado.")); } if (!updatedContact.Valid) { return(ValidationProblem(updatedContact.GetAllNotifications())); } return(Ok(updatedContact)); }
public ActionResult Edit(EditContactViewModel model) { if (ModelState.IsValid) { return(View(model)); } Contact existing = _contactService.GetContactById(model.ContactId); existing.FirstName = model.FirstName; existing.LastName = model.LastName; existing.PhoneNumber = model.PhoneNumber; existing.Address1 = model.Address1; existing.Address2 = model.Address2; existing.City = model.City; existing.State = model.State; existing.ZipCode = model.ZipCode; existing.HasPublicProfile = model.HasPublicProfile; _contactService.EditContact(existing); return(RedirectToAction("Details")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Type,Value,PersonId")] EditContactViewModel contact) { if (id != contact.Id) { return(NotFound()); } if (ModelState.IsValid) { try { Contact c = new Contact { Id = contact.Id, PersonId = contact.PersonId, Type = contact.Type, Value = contact.Value }; await _contactsRepository.UpdateContactsAsync(c); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["PersonId"] = new SelectList(await _peopleRepository.GetPeopleAsync(), "Id", "Nome", contact.PersonId); return(View(contact)); }
public PartialViewResult AddContact() { var viewModel = new EditContactViewModel(); return(ViewAddContact(viewModel, null)); }