Exemple #1
0
        public void Create_Void_ReturnId()
        {
            _contact.Id = _contactRepository.Create(_contact);
            var result = _contactRepository.Get(_contact.Id);

            AreEqualContacts(result, _contact);
        }
Exemple #2
0
        public int Create(ContactViewModel contactViewModel, Distributor distributor)
        {
            try
            {
                var contactToCreate = new Contact();
                contactToCreate.DistributorId = distributor.Id;
                MapViewModelToModel(contactViewModel, ref contactToCreate);

                return(_contactRepository.Create(contactToCreate));
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Exemple #3
0
        public ActionResult CreateOption(Contact Model)
        {
            ContactRepository Repo = new ContactRepository();

            Repo.Create(Model);
            return(Ok());
        }
        public void CreateOnContactRepository()
        {
            //Arrange
            var mockContactNumberRepository = new Mock<IContactNumberRepository>();
            ContactRepository contactRepository = new ContactRepository(_config, mockContactNumberRepository.Object);

            var contactToCreate = new Contact
            {
                UserId = _users[0].Id,
                Title = "Mrs",
                Forename = "Maggie",
                Surname = "Thatcher",
                Email = "*****@*****.**"
            };

            //Act
            Guid id = contactRepository.Create(contactToCreate);

            Contact contact = contactRepository.Get(id);

            //Assert
            Assert.AreEqual(contact, contactToCreate);
            Assert.IsNotNull(id);

            contactRepository.Dispose();
        }
Exemple #5
0
        public ResponseMessage Create(Contact entity)
        {
            ResponseMessage response = new ResponseMessage();

            _repository.Create(entity);

            return(response);
        }
        public async Task <ActionResult <ContactSkillRepresentation> > Post(ContactSkillSimplifiedRepresentation entity)
        {
            var contact = _mapper.Map <ContactRepresentation, Contact>(entity.Contact);

            contact = await _repository.Create(contact, entity.SkillIds);

            return(_mapper.Map <ContactSkillRepresentation>(contact));
        }
Exemple #7
0
        public ActionResult Create(string name, string email)
        {
            ContactRepository repos = new ContactRepository();

            repos.Create(name, email);

            //return View("~/Views/Contact/Index.cshtml", repos.GetAll());
            return(RedirectToAction("Index"));
        }
Exemple #8
0
        public bool Create(ContactCreateApiModel apiModel, int createdUser)
        {
            var validator = _contactValidator.Validate(apiModel);

            if (validator.IsValid)
            {
                return(_contactRepository.Create(apiModel, createdUser));
            }
            return(false);
        }
Exemple #9
0
 /// <summary>
 /// Add's a new Contact to DB
 /// </summary>
 /// <param name="contactInfo"></param>
 public void AddContact(PersonData.Contact contactInfo)
 {
     try
     {
         RepositoryContact.Create(contactInfo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public ContactPageViewModel()
        {
            _repository = new ContactRepository();

            SaveCommand = new RelayCommand(o => {
                var contact = new Contact {
                    Name = Name, Email = Email, Message = Message
                };
                _repository.Create(contact);
                BackCommand?.Execute(null);
            });
        }
Exemple #11
0
        [HttpPost] /*POSTMAN OK*/
        public IActionResult Create([FromBody] Contact contact)
        {
            switch (_contactRepo.Create(contact.ApitoDal()))
            {
            case DBErrors.Success:
                return(Ok());

            case DBErrors.NationalNumber_Exist:
                return(Problem("NationalNumber already exist.", statusCode: (int)HttpStatusCode.BadRequest));

            case DBErrors.NullExeption:
                return(Problem("A mandatory field does not support 'null' value or is missing", statusCode: (int)HttpStatusCode.BadRequest));

            default:
                return(Problem("?", statusCode: (int)HttpStatusCode.NotFound));
            }
        }
        public void CRUD_Tests()
        {
            var contactA = new Contact
            {
                FirstName    = "Test",
                LastName     = "User01",
                EmailAddress = "*****@*****.**",
                DateCreated  = DateTime.UtcNow,
                Active       = true
            };

            var contactRepository = new ContactRepository("MyTestTable", "MyTestPartitionKey");

            //Create
            contactRepository.Create(contactA);
            Assert.IsTrue(contactA.Id != Guid.Empty);

            // Read
            var contactB = contactRepository.Find(contactA.Id);

            Assert.AreEqual(contactA.FirstName, contactB.FirstName);
            Assert.AreEqual(contactA.LastName, contactB.LastName);
            Assert.AreEqual(contactA.EmailAddress, contactB.EmailAddress);
            Assert.AreEqual(contactA.DateCreated, contactB.DateCreated);
            Assert.AreEqual(contactA.Active, contactB.Active);

            // Update
            contactB.LastName = "Last Name Changed";
            contactRepository.Update(contactB);

            var contactC = contactRepository.Find(contactB.Id);

            Assert.IsNotNull(contactC);
            Assert.AreEqual(contactC.LastName, contactB.LastName);

            // Delete
            var deleteResult = contactRepository.Delete(contactC.Id);
            var contactD     = contactRepository.Find(contactC.Id);

            Assert.IsTrue(deleteResult);
            Assert.IsNull(contactD);
        }
Exemple #13
0
        public ActionResult Create(Contact contact)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _contact.Create(contact);

                    ViewBag.Message = "Contact added successfuly";
                }
                catch (Exception ex)
                {
                    Common.LogError(ModuleType.Create, ex);
                }

                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
        public void FindAll_ReturnsAllContacts()
        {
            var contactRepository = new ContactRepository("MyTestTable", "MyTestPartitionKey");


            for (int i = 0; i < 10; i++)
            {
                var contact = new Contact
                {
                    FirstName   = "Test",
                    LastName    = string.Format("Contact{0}", i),
                    DateCreated = DateTime.UtcNow,
                    Active      = true
                };
                contactRepository.Create(contact);
            }

            var contacts = contactRepository.FindAll();

            Assert.IsTrue(contacts.Count >= 10);
        }
Exemple #15
0
        public void ContactCRUDTest()
        {
            var context = new NoodleDbContext("NoodleDb");

            IContactRepository service = new ContactRepository(context);

            var ID_          = Guid.NewGuid();
            var RECORD_GUID_ = Guid.NewGuid();
            var TYPE_        = "ТИП";

            var record = new Contact
            {
                Id         = ID_,
                RecordGuid = RECORD_GUID_,
                Type       = TYPE_
            };

            service.Create(record);

            record.RecordGuid = Guid.NewGuid();
            record.Type       = "ТИП1";

            service.Update(record);

            var record2 = service.GetById(ID_);

            Assert.AreEqual(record.Id, record2.Id);
            Assert.AreEqual(record.RecordGuid, record2.RecordGuid);
            Assert.AreEqual(record.Type, record2.Type);

            service.Delete(record.Id);

            var record3 = service.GetById(ID_);

            Assert.IsNull(record3);
        }
        public IHttpActionResult Add(Contact contact)
        {
            ContactRepository.Create(contact);

            return(Created($"contact/{contact.ContactId}", contact));
        }
Exemple #17
0
 public bool Create(Contact contact)
 {
     return(db.Create(contact));
 }