예제 #1
0
        /// <summary>
        /// Creates new PhoneBook
        /// </summary>
        /// <param name="request">Object which defines PhoneBook</param>
        /// <returns>Error message and status if one occured</returns>
        public BaseResponse Create(CreatePhoneBookRequest request)
        {
            BaseResponse response = new BaseResponse();
            PhoneBook entity = Mapper.Map<CreatePhoneBookRequest, PhoneBook>(request);
            entity.UserId = GetUserId();

            phoneBookRepository.Insert(entity);
            phoneBookRepository.Save();

            return response;
        }
예제 #2
0
        public void Configure_MapCreatePhoneBookRequestToPhoneBook_ValidMapping()
        {
            string firstName = "abc";
            string lastName = "efg";
            string number = "123";
            int phoneTypeId = 1;
            CreatePhoneBookRequest request = new CreatePhoneBookRequest { FirstName = firstName, LastName = lastName, Number = number, PhoneTypeId = phoneTypeId };

            PhoneBook phoneBook = Mapper.Map<CreatePhoneBookRequest, PhoneBook>(request);

            Assert.AreEqual(firstName, request.FirstName);
            Assert.AreEqual(lastName, request.LastName);
            Assert.AreEqual(number, request.Number);
            Assert.AreEqual(phoneTypeId, request.PhoneTypeId);
        }