public ActionResult Detail(string id) { if (string.IsNullOrEmpty(id)) { return(View("Error", new HandleErrorInfo(new Exception("Id is invalid."), "Directory", "Detail"))); } ContactInfoDB contactInfo = new ContactInfoDB(); FamilyInfoDBModel familyInfoDBModel = contactInfo.SelectWithKidsInfo(id); if (familyInfoDBModel == null || familyInfoDBModel.FamilyContactGuid == null) { return(View("Error", new HandleErrorInfo(new Exception("User Id not found."), "Directory", "Detail"))); } else { ContactInfoViewModel viewModel = ProcessDBModeltoViewModel(familyInfoDBModel); if (viewModel == null) { return(View("Error", new HandleErrorInfo(new Exception("Error Processing Data."), "Directory", "Detail"))); } else { return(View(viewModel)); } } }
public async Task <ActionResult> Create(int contactId, string returnUrl) { SqlQuery query = new SqlQuery { Filter = "id = " + contactId }; Contact contact = (await databaseApi.GetRecordsAsync <Contact>("contact", query)).Records.FirstOrDefault(); if (contact == null) { return(Redirect(returnUrl)); } ViewBag.ContactName = string.Format("{0} {1}", contact.FirstName, contact.LastName); ContactInfoViewModel model = new ContactInfoViewModel { ContactInfo = new ContactInfo { ContactId = contactId }, ReturnUrl = returnUrl }; return(View(model)); }
public async Task <ActionResult> Edit(int id, string returnUrl) { SqlQuery contactInfoQuery = new SqlQuery { Filter = "id = " + id, Related = "contact_by_contact_id" }; ContactInfo contactInfo = (await databaseApi.GetRecordsAsync <ContactInfo>("contact_info", contactInfoQuery)).Records.FirstOrDefault(); if (contactInfo == null) { return(Redirect(returnUrl)); } ContactInfoViewModel model = new ContactInfoViewModel { InfoType = (InfoType)Enum.Parse(typeof(InfoType), contactInfo.InfoType, true), ContactInfo = contactInfo, ContactName = string.Format("{0} {1}", contactInfo.Contact.FirstName, contactInfo.Contact.LastName), ReturnUrl = returnUrl }; return(View(model)); }
public static AddCompanyViewModel RegCompanySuccess() { UserInfoViewModel userInfo = new UserInfoViewModel { FirstName = "Ислам", SecondName = "Байгазиев", MiddleName = "Test", BirthDay = "13.09.1998", Email = "*****@*****.**", Inn = "12345678912345", }; ContactInfoViewModel contactInfo = new ContactInfoViewModel { MobilePhone = "0555800565" }; AddCompanyViewModel model = new AddCompanyViewModel { NameCompany = "Samsung", InnCompany = "12345678912345", OkpoCompany = "Test", DateOfInitialRegistration = "13.09.1998", DateOfRegistrationMinistryJustice = "13.09.2017", RegistrationNumberSocialFund = "654116513", NumberOfEmployees = 1, ContactInfo = contactInfo, RegistrationAuthority = "CKK", IssuedBy = "Stalin" }; return(model); }
public static RegisterPersonViewModel RegPersonSuccess() { UserInfoViewModel userInfo = new UserInfoViewModel { FirstName = "Ислам", SecondName = "Байгазиев", MiddleName = "Test", BirthDay = "13.09.1998", Email = "*****@*****.**", Inn = "12345678912345", }; PassportInfoViewModel passportInfo = new PassportInfoViewModel { Series = "AN", DateofExtradition = "12.05.2011", Validaty = "12.05.2016", IssuedBy = "Lenin", Number = "6542164", }; ContactInfoViewModel contactInfo = new ContactInfoViewModel { MobilePhone = "0555800565" }; RegisterPersonViewModel model = new RegisterPersonViewModel { UserInfo = userInfo, PassportInfo = passportInfo, ContactInfo = contactInfo, }; return(model); }
public HttpResponseMessage CreateContactInfo(ContactInfoViewModel contactInfoVM) { try { if (ModelState.IsValid) { var contactInfo = new ContactInfo { FullName = contactInfoVM.FirstName + " " + contactInfoVM.LastName, Telephone1 = contactInfoVM.Telephone1, Telephone2 = contactInfoVM.Telephone2, EmailAddress = contactInfoVM.EmailAddress }; _context.ContactInfos.Add(contactInfo); _context.SaveChanges(); message = Request.CreateResponse(HttpStatusCode.Created, "Contact Info Created Successfully"); } return(message); } catch (Exception ex) { message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(message); } }
public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { return(View("Error", new HandleErrorInfo(new Exception("Id is invalid."), "Directory", "Detail"))); } ContactInfoDB contactInfo = new ContactInfoDB(); FamilyInfoDBModel familyInfoDBModel = contactInfo.SelectWithKidsInfo(id); if (familyInfoDBModel == null || familyInfoDBModel.FamilyContactGuid == null) { return(View("Error", new HandleErrorInfo(new Exception("User Id not found."), "Directory", "Detail"))); } else { ContactInfoViewModel viewModel = ProcessDBModeltoViewModel(familyInfoDBModel); if (viewModel == null) { return(View("Error", new HandleErrorInfo(new Exception("Error Processing Data."), "Directory", "Detail"))); } var kidsCount = (viewModel.Kids == null) ? 0 : viewModel.Kids.Count; //Fill in the rest of the Kids field with empty string for view for (int i = 0; i < (5 - kidsCount); i++) { viewModel.Kids.Add(new KidsViewModel()); } return(View(viewModel)); } }
public ContactInfoView(AntSdkContact_User user, GlobalVariable.ContactInfoViewContainer container) { InitializeComponent(); ContactInfoViewModel model = new ContactInfoViewModel(user, container); DataContext = model; }
public HttpResponseMessage EditContactInfo(ContactInfoViewModel contactInfoVM) { try { if (ModelState.IsValid) { var contactInfo = _context.ContactInfos.FirstOrDefault(c => c.Id == contactInfoVM.Id); if (contactInfo == null) { message = Request.CreateResponse(HttpStatusCode.NotFound, "Sorry Contact, does not exist"); } else { contactInfo.FullName = contactInfoVM.FirstName + " " + contactInfoVM.LastName; contactInfo.Telephone1 = contactInfoVM.Telephone1; contactInfo.Telephone2 = contactInfoVM.Telephone2; contactInfo.EmailAddress = contactInfoVM.EmailAddress; _context.SaveChanges(); message = Request.CreateResponse(HttpStatusCode.OK, "Contact info updated successfully"); } } return(message); } catch (Exception ex) { message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(message); } }
public ActionResult EditAjax(int id, ContactInfoViewModel viewModel) { try { if (ModelState.IsValid) { ContactInfoViewModel editViewModel = _iContactInfoService.GetContactInfo(id); if (editViewModel != null) { if (_iContactInfoService.Create(editViewModel) > 0) { InformLog("Data updated successfully.", "Contact updated."); return(Json(new { msg = "Data updated successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet)); } else { InformLog("Data could not updated.", "Contact could not updated."); return(Json(new { msg = "Data could not updated.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } } InformLog("This data are missing.", "Contact could not updated."); return(Json(new { msg = "This data are missing.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } InformLog("Model could not valided.", "Contact could not updated."); return(Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLog(ex); return(Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet)); } }
public void OnPageHandlerExecuted(PageHandlerExecutedContext context) { var result = context.Result; if (result is PageResult pageResult) { var viewData = pageResult.ViewData; if (!this._memoryCache.TryGetValue(GlobalConstants.ApplicationInfo, out ContactInfoViewModel model)) { model = new ContactInfoViewModel() { AppName = this._settingsService.Get(GlobalConstants.ApplicationNameKey), AppFooterAboutContent = this._settingsService.Get(GlobalConstants.ApplicationAboutFooterKey), AppAddress = this._settingsService.Get(GlobalConstants.ApplicationAddressKey), AppEmail = this._settingsService.Get(GlobalConstants.ApplicationEmailKey), AppPhone = this._settingsService.Get(GlobalConstants.ApplicationPhoneKey) }; var cacheOption = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromHours(GlobalConstants.ApplicationInfoCacheExpirationDay)); this._memoryCache.Set(GlobalConstants.ApplicationInfoCacheExpirationDay, model, cacheOption); } viewData[GlobalConstants.ApplicationInfo] = model; } }
public ActionResult Create(ContactInfoViewModel model) { ValidateModel(model); if (!ModelState.IsValid) { return(View(model)); } //Process Data to Create Data Model FamilyInfoDBModel familyContact = ProcessViewModeltoDBModel(model); //Insert into DB ContactInfoDB contactInfoDB = new ContactInfoDB(); contactInfoDB.InsertFamilyInfo(familyContact); //Upload Pic to Azure. var familyPic = model.FamilyPic; if (familyPic != null && familyPic.ContentLength != 0 && !string.IsNullOrWhiteSpace(familyContact.FamilyPicFileName)) { var mediaFileName = familyContact.FamilyPicFileName; new AzureFileStorage().UploadFile(mediaFileName, familyPic.InputStream); } //Send Email. GMailDispatcher mailDispatcher = new GMailDispatcher(); mailDispatcher.SendCreateConfirmMsg(familyContact.Email, familyContact.FirstName + " " + familyContact.LastName, familyContact.FamilyContactGuid); return(View("CreateConfirm")); }
public IActionResult TouchpointUpdate(ContactInfoViewModel model) { if (!ModelState.IsValid) { return(View()); } foreach (var touchpoint in model.Touchpoints) { var oldTouchpoint = _touchpointRepository.GetById(touchpoint.Id); oldTouchpoint.Date = touchpoint.Date; oldTouchpoint.SortOfEvent = touchpoint.SortOfEvent; oldTouchpoint.Description = touchpoint.Description; oldTouchpoint.Reminder = touchpoint.Reminder; var response = _touchpointRepository.Update(oldTouchpoint); if (response == null || response.Id == 0) { return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public HttpResponseMessage GetContactInfoById(int Id) { try { var contactInfo = _context.ContactInfos.FirstOrDefault(c => c.Id == Id); if (contactInfo == null) { message = Request.CreateResponse(HttpStatusCode.NotFound, "Sorry Contact, does not exist"); return(message); } else { var contactInfoVM = new ContactInfoViewModel { Id = contactInfo.Id, FullName = contactInfo.FullName, Telephone1 = contactInfo.Telephone1, Telephone2 = contactInfo.Telephone2, EmailAddress = contactInfo.EmailAddress }; message = Request.CreateResponse(HttpStatusCode.OK, contactInfoVM); return(message); } } catch (Exception ex) { message = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); return(message); } }
public IActionResult ContactUpdate(ContactInfoViewModel model) { if (!ModelState.IsValid) { return(View()); } foreach (var contact in model.Contacts) { var oldContact = _contactRepository.GetById(contact.Id); oldContact.FirstName = contact.FirstName; oldContact.LastName = contact.LastName; oldContact.Role = contact.Role; oldContact.Email = contact.Email; oldContact.Phone = contact.Phone; oldContact.Mkt = contact.Mkt; oldContact.CIOCircle = contact.CIOCircle; oldContact.InnovationForum = contact.InnovationForum; oldContact.TAC = contact.TAC; oldContact.PostalAddress = contact.PostalAddress; oldContact.Comments = contact.Comments; var response = _contactRepository.Update(oldContact); if (response == null || response.Id == 0) { return(RedirectToAction("Index")); } } return(RedirectToAction("Index")); }
public ContactInfoViewModel Get() { // Get Person data model from the data service var person = service.GetPersonByUsername(authenticatedUser, new PersonIncludes { Accounts = false, Addressses = true, Phones = true, AccountTransactions = false }); // Create a Holder view model and populate data from Person data model var contactInfo = new ContactInfoViewModel(); contactInfo.EmailAddress = person.EmailAddress; contactInfo.Addresses = (from a in person.Addresses select new AddressViewModel { AddressID = a.AddressID, Type = a.AddressType.Name, StreetAddress = a.Address.StreetAddress, City = a.Address.City, State = a.Address.State, Zip = a.Address.Zip, AddressTypeID = a.AddressTypeID }).ToList(); contactInfo.PhoneNumbers = (from p in person.Phones select new PhoneViewModel { PhoneType = p.PhoneType.Name, PhoneTypeID = p.PhoneTypeID, Number = p.Number }).ToList(); return(contactInfo); }
public int Update(ContactInfoViewModel contactInfoViewModel) { var contactInfo = EmContactInfo.SetToModel(contactInfoViewModel); _iContactInfoRepository.Update(contactInfo); return(Save()); }
public ActionResult DeleteConfirmed(int id) { try { ContactInfoViewModel deleteViewModel = _iContactInfoService.GetContactInfo(id); if (deleteViewModel != null) { if (_iContactInfoService.Delete(deleteViewModel) > 0) { InformLog("Data deleted successfully.", "Contact deleted."); return(Json(new { msg = "Data deleted successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet)); } else { InformLog("Data could not deleted.", "Contact could not deleted."); return(Json(new { msg = "Data could not deleted.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } } InformLog("This data are missing.", "Contact could not deleted."); return(Json(new { msg = "This data are missing.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLog(ex); return(Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddAjax(ContactInfoViewModel viewModel) { try { if (ModelState.IsValid) { if (_iContactInfoService.Create(viewModel) > 0) { InformLog("Data saved successfully.", "Contact saved."); return(Json(new { msg = "Data saved successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet)); } else { InformLog("Data could not saved.", "Contact could not saved."); return(Json(new { msg = "Data could not saved.", status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } } InformLog("Model could not valided.", "Contact could not saved."); return(Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.notice.ToString() }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLog(ex); return(Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet)); } }
private void ValidateModel(ContactInfoViewModel model) { var mStatus = model.MaritalStatus ?? string.Empty; if (mStatus == "M") { // Check Spouse Info if (string.IsNullOrWhiteSpace(model.SpouseFirstName)) { ModelState.AddModelError("Spouse First Name", "Spouse's First Name is required"); } if (string.IsNullOrWhiteSpace(model.SpouseLastName)) { ModelState.AddModelError("Spouse Last Name", "Spouse's Last Name is required"); } if (string.IsNullOrWhiteSpace(model.SpouseKovil)) { ModelState.AddModelError("Spouse Kovil", "Spouse's Kovil at Birth is required"); } if (string.IsNullOrWhiteSpace(model.SpouseKovilPirivu)) { ModelState.AddModelError("Spouse Kovil Pirivu", "Spouse's Kovil Pirivu at Birth is required"); } } var familyPic = model.FamilyPic; if (familyPic != null && familyPic.ContentLength != 0) { var fileExtension = Path.GetExtension(familyPic.FileName).ToLower(); var index = Array.IndexOf(allowedExtension, fileExtension); if (index < 0) { ModelState.AddModelError("Family Picture", "Only Images are allowed for Family Picture."); } model.FamilyPicFileExtn = fileExtension; } //Validate Kids Information if present foreach (var kidsInfo in model.Kids) { if (string.IsNullOrWhiteSpace(kidsInfo.FirstName) && !(kidsInfo.Age.HasValue) && string.IsNullOrWhiteSpace(kidsInfo.Gender)) { continue; } if (string.IsNullOrWhiteSpace(kidsInfo.FirstName)) { ModelState.AddModelError("Kid First Name", "Kid's First Name is required"); } if (string.IsNullOrWhiteSpace(kidsInfo.Gender)) { ModelState.AddModelError("Kid Gender", "Kid's Gender is required"); } if (!(kidsInfo.Age.HasValue)) { ModelState.AddModelError("Kid Age", "Kid's Age is required"); } } }
public int Delete(ContactInfoViewModel contactInfoViewModel) { var deleteContactInfo = GetContactInfo(contactInfoViewModel.ContactInfoId); var contactInfo = EmContactInfo.SetToModel(deleteContactInfo); _iContactInfoRepository.Delete(contactInfo); return(Save()); }
// PUT: /api/contactinfo public void Put([FromBody] ContactInfoViewModel contactInfoViewModel) { // Get Person data model from the data service // we do not need account nor transactions var person = service.GetPersonByUsername(authenticatedUser, new PersonIncludes { Accounts = false, Addressses = false, Phones = false, AccountTransactions = false }); // Update the Email Address in the person model person.EmailAddress = contactInfoViewModel.EmailAddress; person.Phones = new List <Phone>(); person.Addresses = new List <PersonAddressAssn>(); // Add the phone numbers to the person model foreach (PhoneViewModel phoneViewModel in contactInfoViewModel.PhoneNumbers) { if (!string.IsNullOrEmpty(phoneViewModel.Number)) { var phone = new Phone { PhoneTypeID = phoneViewModel.PhoneTypeID, Number = phoneViewModel.Number }; person.Phones.Add(phone); } } // Add the addresses to the person model foreach (AddressViewModel addressViewModel in contactInfoViewModel.Addresses) { if (!string.IsNullOrEmpty(addressViewModel.StreetAddress)) { var address = new PersonAddressAssn { AddressTypeID = addressViewModel.AddressTypeID, Address = new Address { StreetAddress = addressViewModel.StreetAddress, City = addressViewModel.City, State = addressViewModel.State, Zip = addressViewModel.Zip } }; person.Addresses.Add(address); } } // Update the data store var oppStatus = service.UpdatePerson(person); // Return success or error state if (!oppStatus.Success) { throw new Exception(oppStatus.Messages[0]); } }
public ActionResult Contact(ContactInfoViewModel contact) { CarDearlershipRespoFacotory.GetRepository().ContactUs( new ContactUs { Name = contact.Name, Phone = contact.Phone, Email = contact.Email, Message = contact.Message }); return(RedirectToAction("Index", "Home")); }
public async Task <ContactInfo> CreateContactInfo(ContactInfoViewModel model) { ContactInfo contactInfo = new ContactInfo { MobilePhone = model.MobilePhone, CityPhone = model.CityPhone, Email = model.Email, FullName = model.FullName, Address = model.Address, PhoneNumber = model.PhoneNumber }; await context.ContactInfos.AddAsync(contactInfo); context.SaveChanges(); return(contactInfo); }
public async Task <ContactInfo> CreateContactInfo(ContactInfoViewModel model) { ContactInfo contactInfo = new ContactInfo { MobilePhone = model.MobilePhone, CityPhone = model.CityPhone, Email = model.Email }; await context.ContactInfos.AddAsync(contactInfo); context.SaveChanges(); return(contactInfo); }
public IActionResult Edit(int id) { Company company = companyService.GetCompanies().FirstOrDefault(c => c.Id == id); RegistrationData registrationData = companyService.FindRegistrationDataById(company.RegistrationDataId); CompanyViewModel companyViewModel = new CompanyViewModel(company); RegistrationDataViewModel registrationDataViewModel = new RegistrationDataViewModel(registrationData); FactAddressViewModel factAddressViewModel = new FactAddressViewModel(); ContactInfoViewModel contactInfoViewModel = new ContactInfoViewModel { CityPhone = company.ContactInfo.CityPhone, MobilePhone = company.ContactInfo.MobilePhone, Email = company.ContactInfo.Email }; Address factAddress = companyService.FindFactAddressByCompanyId(company.Id); if (factAddress != null) { factAddressViewModel.CountryId = factAddress.CountryId; factAddressViewModel.City = factAddress.City; factAddressViewModel.Street = factAddress.Street; factAddressViewModel.HouseAddress = factAddress.HouseAddress; factAddressViewModel.PostCode = factAddress.PostCode; } LegalAddressViewModel legalAddressViewModel = new LegalAddressViewModel(); Address legalAddress = companyService.FindLegalAddressByCompanyId(company.Id); if (factAddress != null) { legalAddressViewModel.CountryId = legalAddress.CountryId; legalAddressViewModel.City = legalAddress.City; legalAddressViewModel.Street = legalAddress.Street; legalAddressViewModel.HouseAddress = legalAddress.HouseAddress; legalAddressViewModel.PostCode = legalAddress.PostCode; } CompanyEditViewModel model = new CompanyEditViewModel { FactAddress = factAddressViewModel, LegalAddress = legalAddressViewModel, Company = companyViewModel, RegistrationData = registrationDataViewModel, ContactInfo = contactInfoViewModel }; model.Countries = selectListService.GetCountries(); model.LegalForms = selectListService.GetLegalForms(); model.PropertyTypes = selectListService.GetPropertyTypes(); model.Residencies = selectListService.GetResidencies(); model.TaxInspections = selectListService.GetTaxInspections(); ViewBag.CountriesForAddress = GetCountriesForAddress(); return(View(model)); }
public async Task <IActionResult> Put([FromBody] ContactInfoViewModel contactInfo) { (bool success, ContactInfoViewModel? vm, RequestError? error) = await new UpdateContactInfo(_context).Do(contactInfo); if (!success && error != null) { return(StatusCode((int)error.StatusCode, error.Errors)); } return(Ok(vm)); }
public ContactInfo ContactInfoEdit(ContactInfo contactInfo, ContactInfoViewModel model) { contactInfo.Address = model.Address; contactInfo.CityPhone = model.CityPhone; contactInfo.FullName = model.FullName; contactInfo.Email = model.Email; contactInfo.MobilePhone = model.MobilePhone; contactInfo.PhoneNumber = model.PhoneNumber; context.ContactInfos.Update(contactInfo); context.SaveChanges(); return(contactInfo); }
private async Task <ContactInfoViewModel> GetReservationCreatorContactInformation(int reservationId) { ContactInfoViewModel contactInfo = await unitOfWork.ReservationsRepository .Include(r => r.NonRegisteredUser, r => r.ClientUser) .Where(r => r.ReservationId == reservationId) .Select(r => new ContactInfoViewModel { Email = r.ClientUserId == null ? r.NonRegisteredUser.ClientEmail : r.ClientUser.Email, PhoneNumber = r.ClientUserId == null ? r.NonRegisteredUser.ClientPhoneNumber : r.ClientUser.PhoneNumber }) .FirstOrDefaultAsync() ?? throw new ContentNotFoundException("Потребителя не е намерен!"); return(contactInfo); }
public async Task <IActionResult> IndexAsync() { var contacts = await _contactRepository.GetAllAsync(); var touchpoints = await _touchpointRepository.GetAllAsync(); var contactInfoViewModel = new ContactInfoViewModel() { Contacts = contacts.ToList(), Touchpoints = touchpoints.ToList(), }; return(View("ContactInfo", contactInfoViewModel)); }
public ActionResult Edit(ContactInfoViewModel vm) { try { if (ModelState.IsValid) { //map viewmodel to view var contactInfo = AutoMapperConfig.TCWMapper.Map<ContactInfo>(vm); //now save model to db _repository.Update(contactInfo); _repository.Save(); return RedirectToAction("Details"); } } catch (Exception ex) { //TODO: add logging } return View(vm); }