예제 #1
0
        // GET api/contacts/5
        public ContactModel Get(int id)
        {
            var user = ((UserCreditsService)_fileUserCredits).GetByUserId(SessionHelper.CurrentUser.Id);

            if (user.Credits >= 5)
            {
                user.Credits = user.Credits - 5;
                _fileUserCredits.Update(user);
                return(JigsawHelper.GetPurchasedContact(id));
            }

            return(null);
        }
예제 #2
0
        public void GetPurchasedContactTest()
        {
            ConfigurationManager.AppSettings["ConnectionInfo"] = "ek49phfby0cs";

            ConfigurationManager.AppSettings["JigsawUserName"] = "******";

            ConfigurationManager.AppSettings["JigsawPassword"] = "******";


            string companyName       = "American Dehydrated Foods, Inc.";
            string expectedCompanyId = "204339";
            string actualCompanyId;

            actualCompanyId = JigsawHelper.GetCompanyId(companyName);
            Assert.AreEqual(expectedCompanyId, actualCompanyId);


            string companyId = actualCompanyId;
            int    expected  = 16;
            int    actual;
            var    model = JigsawHelper.GetContacts(companyId);

            actual = model.Count;

            Assert.AreEqual(expected, actual);

            long   contactId = model[0].ContactId;
            string email     = "*****@*****.**";
            string address   = "PO BOX 4087";
            string phone     = "+1.417.881.7755";


            var contactInfo = JigsawHelper.GetPurchasedContact(contactId);


            Assert.AreEqual(email, contactInfo.Email);
            Assert.AreEqual(address, contactInfo.Address);
            Assert.AreEqual(phone, contactInfo.Phone);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
예제 #3
0
        // GET api/contacts/5
        public ContactModel Get(int id)
        {
            var session = _accessor.Current().Session;

            if (session != null)
            {
                var fileList = session["CurrentUser"] as UserModel;
                if (fileList != null)
                {
                    var user = ((UserCreditsService)_fileUserCredits).GetByUserId(fileList.Id);

                    if (user.Credits >= 5)
                    {
                        user.Credits = user.Credits - 5;
                        _fileUserCredits.Update(user);
                        return(JigsawHelper.GetPurchasedContact(id));
                    }
                }
            }


            return(null);
        }