예제 #1
0
        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));
        }
예제 #2
0
        // 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));
        }
예제 #3
0
        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));
        }
예제 #5
0
        /*
         * 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));
        }
예제 #6
0
        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());
        }
예제 #7
0
        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());
        }
예제 #8
0
        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);
        }
예제 #10
0
        public async Task <ActionResult> Importer(Guid id)
        {
            var importer = await mediator.SendAsync(new GetImporterByNotificationId(id));

            var model = new EditContactViewModel(importer);

            return(View(model));
        }
예제 #11
0
        private static ImporterData GetNewImporterData(EditContactViewModel model, ImporterData oldImporterData)
        {
            var newImporterData = new ImporterData
            {
                Contact  = GetNewContactData(model, oldImporterData.Contact),
                Business = GetNewBusinessInfoData(model, oldImporterData.Business)
            };

            return(newImporterData);
        }
예제 #12
0
        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));
        }
예제 #13
0
        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));
            }
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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));
        }
예제 #18
0
        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);
        }
예제 #20
0
        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));
        }
예제 #21
0
        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"));
        }
예제 #22
0
 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);
        }
예제 #24
0
        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"));
        }
예제 #25
0
        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));
        }
예제 #26
0
        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"));
        }
예제 #27
0
        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));
        }
예제 #28
0
        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"));
        }
예제 #29
0
        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));
        }
예제 #30
0
        public PartialViewResult AddContact()
        {
            var viewModel = new EditContactViewModel();

            return(ViewAddContact(viewModel, null));
        }