示例#1
0
        private static void MigrateContaqct()
        {
            var contactRepository = new ContactRepository(_mongoDbProvider);
            var dataBaseDir       = "C:\\dev\\Phillip Buttrose\\Guitars\\Web\\assets\\contact";

            var jsonData         = File.ReadAllText(Path.Combine(dataBaseDir, "data.json"));
            var contactViewModel = JsonConvert.DeserializeObject <ContactViewModel>(jsonData);
            var adoutDataModel   = new ContactDataModel
            {
                _id           = new ObjectId(),
                Header1       = contactViewModel.Header1,
                Header2       = contactViewModel.Header2,
                Address       = contactViewModel.Address,
                BusinessHours = contactViewModel.BusinessHours.ConvertAll((b) => new BusinessHourDataModel {
                    Day = b.Day, Hours = b.Hours
                }),
                Email     = contactViewModel.Email,
                GoogleMap = contactViewModel.GoogleMap,
                Phone     = contactViewModel.Phone,
                Spot      = new SpotDataModel {
                    Left = contactViewModel.Spot.Left, Top = contactViewModel.Spot.Top
                },
                Map = _imageConverter.Convert(Image.FromFile(Path.Combine(dataBaseDir, contactViewModel.Map)))
            };

            contactRepository.Purge();
            contactRepository.Save(adoutDataModel);
        }
示例#2
0
        public ActionResult Contact(ContactViewModel viewModel)
        {
            string EncodedResponse = Request.Form["g-Recaptcha-Response"];
            bool   IsCaptchaValid  = (captchaHelper.Validate(EncodedResponse) == "true");

            if (!IsCaptchaValid || !ModelState.IsValid)
            {
                ViewBag.Success      = false;
                viewModel.Categories = BuildCategoriesList();
                return(View(viewModel));
            }

            var dataModel = new ContactDataModel
            {
                Name     = viewModel.Name,
                Email    = viewModel.Email,
                Category = viewModel.SelectedCategory,
                Message  = viewModel.Message,
                DateTime = DateTime.Now
            };

            dbContext.ContactSubmissions.Add(dataModel);
            dbContext.SaveChanges();

            ModelState.Clear();
            ViewBag.Success = true;

            return(View(new ContactViewModel
            {
                Categories = BuildCategoriesList()
            }));
        }
示例#3
0
        public ContactDataModel VerifyReCaptchaResponse(ContactDataModel model)
        {
            try
            {
                using (var webClient = new HttpClient())
                {
                    var reCaptchaVerifyParams = new Dictionary <string, string>
                    {
                        { "secret", ConfigurationManager.AppSettings["reCapthchaSecretKey"] },
                        { "response", model.RecaptchaResponse }
                    };

                    //webClient.BaseAddress = new Uri("https://www.google.com/recaptcha/api/siteverify");
                    var content  = new StringContent(JsonConvert.SerializeObject(reCaptchaVerifyParams), Encoding.UTF8, "application/json");
                    var postData = webClient.PostAsync("https://www.google.com/recaptcha/api/siteverify", content).Result;
                    postData.EnsureSuccessStatusCode();
                }

                return(model);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CompanyName,BussinessTaxNumber,City,Address,ContactPerson,MobilePhone,Email")] ContactDataModel contactDataModel)
        {
            if (id != contactDataModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contactDataModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactDataModelExists(contactDataModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactDataModel));
        }
        public async Task <IActionResult> Create([Bind("Id,CompanyName,BussinessTaxNumber,City,Address,ContactPerson,MobilePhone,Email")] ContactDataModel contactDataModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contactDataModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactDataModel));
        }
        public bool UpdateContact(ContactDataModel updatedContact)
        {
            using (var connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                var rowAffected = connection.Execute(
                    @"EXEC dbo.Contact_Update @UserId = @UserId, @ContactId = @ContactId, @LastUpdateTime = @LastUpdateTime",
                    updatedContact);

                return(rowAffected > 0);
            }
        }
示例#7
0
        public void ShouldRetrieveDataModelFromMongoLab()
        {
            // Arrange
            var contactDataModel = new ContactDataModel();

            _mongoDbProvider.Get <ContactDataModel>("contact").Returns(contactDataModel);

            // Act
            var result = _repositoryUnderTest.Get();

            // Assert
            Assert.That(result, Is.EqualTo(contactDataModel));
        }
示例#8
0
        public void ShouldSaveDataModelToMongoLab()
        {
            // Arrange
            var contactDataModel = new ContactDataModel();

            _mongoDbProvider.Update <ContactDataModel>("contact", contactDataModel).Returns(contactDataModel);

            // Act
            var result = _repositoryUnderTest.Save(contactDataModel);

            // Assert
            Assert.That(result, Is.EqualTo(contactDataModel));
        }
        public void UpdateContact()
        {
            var repo           = new ContactRepository(ConnectionString);
            var updatedContact = new ContactDataModel
            {
                UserId         = 1,
                ContactId      = 3,
                LastUpdateTime = DateTime.Parse("2019-05-18 16:25")
            };

            repo.UpdateContact(updatedContact);

            var contact = repo.GetUserContact(1, 3);

            Assert.True(contact.LastUpdateTime == updatedContact.LastUpdateTime);
        }
        public void SeacrchUserContacts()
        {
            var repo            = new ContactRepository(ConnectionString);
            var expectedContact = new ContactDataModel
            {
                UserId         = 1,
                ContactId      = 3,
                LastUpdateTime = DateTime.Parse("2019-05-18 16:25")
            };

            var contact = repo.SearchUserContacts(1, "Mark");

            Assert.True(
                contact.UserId == expectedContact.UserId &&
                contact.ContactId == expectedContact.ContactId &&
                contact.LastUpdateTime == expectedContact.LastUpdateTime);
        }
示例#11
0
        public IHttpActionResult AddContact([FromBody] ContactDataModel model)
        {
            // todo: api docs should reflect that the RecaptchaResponse is not emitted

            var verifiedModel = _contactApiWorkerServcice.VerifyReCaptchaResponse(model);

            if (verifiedModel == null)
            {
                return(new InternalServerErrorResult(Request));
            }
            else
            {
                var contactRepository = _resolver.Resolve <IContactRepository>();
                var savedContact      = contactRepository.Add(model.Contact);

                return(Ok(_contactApiWorkerServcice.GetContactDataModel(savedContact)));
            }
        }
        public void GetUserContact()
        {
            var repo            = new ContactRepository(ConnectionString);
            var expectedContact = new ContactDataModel
            {
                UserId         = 1,
                ContactId      = 2,
                LastUpdateTime = DateTime.Parse("2019-05-18 16:20")
            };

            var contact = repo.GetUserContact(1, 2);

            Assert.True(
                expectedContact.ContactId == contact.ContactId &&
                expectedContact.UserId == contact.UserId &&
                expectedContact.LastUpdateTime == contact.LastUpdateTime
                );
        }
        public void AddContact()
        {
            var repo       = new ContactRepository(ConnectionString);
            var newContact = new ContactDataModel
            {
                UserId         = 4,
                ContactId      = 1,
                LastUpdateTime = DateTime.Parse("2020-05-18 16:25")
            };

            repo.AddContact(newContact);

            var contact = repo.GetUserContact(4, 1);

            Assert.True(
                contact.UserId == newContact.UserId &&
                contact.ContactId == newContact.ContactId &&
                contact.LastUpdateTime == newContact.LastUpdateTime);
        }
示例#14
0
        public async Task <IActionResult> AddOrEdit([Bind("Id,Company,First_Name,Last_Name,Job_Title,Email,Phone,Fax,Complex,Street_1,Street_2,City,Postal_Code,Province,Country,Created")] ContactDataModel contactDataModel)
        {
            if (ModelState.IsValid)
            {
                if (contactDataModel.Id == 0)
                {
                    _context.Add(contactDataModel);
                }
                else
                {
                    _context.Update(contactDataModel);
                }

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contactDataModel));
        }
示例#15
0
        public void ShouldSetupContact()
        {
            var          contactRepository = new ContactRepository(_mongoDbProvider);
            const string dataBaseDir       = "C:/dev/Phillip Buttrose/Guitars/Web/assets/contact";

            Console.WriteLine("MigrateContact - purge");

            contactRepository.Purge();

            Console.WriteLine("MigrateContact - load");

            var jsonData         = File.ReadAllText(Path.Combine(dataBaseDir, "data.json"));
            var contactViewModel = JsonConvert.DeserializeObject <ContactViewModel>(jsonData);
            var adoutDataModel   = new ContactDataModel
            {
                _id           = new ObjectId(),
                Header1       = contactViewModel.Header1,
                Header2       = contactViewModel.Header2,
                Address       = contactViewModel.Address,
                BusinessHours = contactViewModel.BusinessHours.ConvertAll((b) => new BusinessHourDataModel {
                    Day = b.Day, Hours = b.Hours
                }),
                Email     = contactViewModel.Email,
                GoogleMap = contactViewModel.GoogleMap,
                Phone     = contactViewModel.Phone,
                Spot      = new SpotDataModel {
                    Left = contactViewModel.Spot.Left, Top = contactViewModel.Spot.Top
                },
                Map = contactRepository.UploadFiles(dataBaseDir, new List <string> {
                    contactViewModel.Map
                }).FirstOrDefault()
            };

            Console.WriteLine("MigrateContact - save");

            contactRepository.Save(adoutDataModel);
        }
示例#16
0
        public ContactDataModel UpdateContact([FromBody] ContactDataModel model)
        {
            var updatedContact = _contactRepository.Update(model.Contact);

            return(_contactApiWorkerServcice.GetContactDataModel(updatedContact));
        }
        public ConnectedUsersViewModel(EMMainViewModel centralEMMain) : base(centralEMMain)
        {
            Subtitle = "Usuarios Conectados";
            ContactDataModel cdm = new ContactDataModel()
            {
                PrivateHomeTelephone  = "76587876",
                PrivateMovilTelephone = "57688887",
                PrivateEmail          = "*****@*****.**",
                OtherHomeTelephone    = "76576788",
                OtherMovilTelephone   = "57665876",
                OtherEmail            = "*****@*****.**"
            };

            //TODO RECORDAR BORRAR ESTO
            UserClientCollection = new List <UserClientModel>()
            {
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                },
                new UserClientModel()
                {
                    NombreyApellidos = "Fulanito Tales Mascuales", Direccion = "Calle 24 entre 15 y 17, Vedado, La Habana", RecomendationLevel = 2, Correo = "*****@*****.**", Telefono = "65465446-3513113", ClientContact = cdm
                }
            };
        }