Exemplo n.º 1
0
        public JsonResult put(PhoneNumberTypeModel PhoneNumberType)
        {
            string query = @"
                    update dbo.PhoneNumberType set
                    ('" + PhoneNumberType.name + @"
                     where phoneNumberTypeID = " + PhoneNumberType.phoneNumberTypeID;

            DataTable     table         = new DataTable();
            string        sqlDataSource = _configuration.GetConnectionString("PhonePersonAppCon");
            SqlDataReader myReader;

            using (SqlConnection myCon = new SqlConnection(sqlDataSource))
            {
                myCon.Open();
                using (SqlCommand myCommand = new SqlCommand(query, myCon))
                {
                    myReader = myCommand.ExecuteReader();
                    table.Load(myReader);

                    myReader.Close();
                    if (myCon != null)
                    {
                        myCon.Close();
                    }
                }

                return(new JsonResult("Updated Successfully"));
            }
        }
Exemplo n.º 2
0
        public static PhoneNumberType ToDomain(this PhoneNumberTypeModel model, PhoneNumberType domain)
        {
            if (model != null)
            {
                domain.Id   = model.Id;
                domain.Type = model.Type;
            }

            return(domain);
        }
Exemplo n.º 3
0
        public void IntegrationTest()
        {
            var connection = TestSession.GetConnection();

            connection.Open();
            #region good insertion and select by id test
            PhoneNumberTypeModel inserted = new PhoneNumberTypeModel();
            inserted.Name         = TestSession.Random.RandomString(50);
            inserted.ModifiedDate = TestSession.Random.RandomDateTime();

            _tested.Insert(connection, new[] { inserted });

            var selectedAfterInsertion = _tested.GetByPrimaryKey(connection, new PhoneNumberTypeModelPrimaryKey()
            {
                PhoneNumberTypeID = inserted.PhoneNumberTypeID,
            });

            CollectionAssert.IsNotEmpty(selectedAfterInsertion);
            var selectedAfterInsert = selectedAfterInsertion.Single();
            Assert.AreEqual(inserted.PhoneNumberTypeID, selectedAfterInsert.PhoneNumberTypeID);
            Assert.AreEqual(inserted.Name, selectedAfterInsert.Name);
            Assert.AreEqual(inserted.ModifiedDate, selectedAfterInsert.ModifiedDate);

            #endregion

            #region update and select by id test
            inserted.Name         = TestSession.Random.RandomString(50);
            inserted.ModifiedDate = TestSession.Random.RandomDateTime();

            _tested.Update(connection, new[] { inserted });

            var selectedAfterUpdateAddresss = _tested.GetByPrimaryKey(connection, new PhoneNumberTypeModelPrimaryKey()
            {
                PhoneNumberTypeID = inserted.PhoneNumberTypeID,
            });

            CollectionAssert.IsNotEmpty(selectedAfterUpdateAddresss);
            var selectedAfterUpdate = selectedAfterUpdateAddresss.Single();
            Assert.AreEqual(inserted.PhoneNumberTypeID, selectedAfterUpdate.PhoneNumberTypeID);
            Assert.AreEqual(inserted.Name, selectedAfterUpdate.Name);
            Assert.AreEqual(inserted.ModifiedDate, selectedAfterUpdate.ModifiedDate);

            #endregion

            #region delete test
            _tested.Delete(connection, new[] { inserted });
            var selectedAfterDeleteAddresss = _tested.GetByPrimaryKey(connection, new PhoneNumberTypeModelPrimaryKey()
            {
                PhoneNumberTypeID = inserted.PhoneNumberTypeID,
            });
            CollectionAssert.IsEmpty(selectedAfterDeleteAddresss);
            #endregion
            connection.Close();
        }
Exemplo n.º 4
0
        public static PhoneNumberType ToDomain(this PhoneNumberTypeModel model)
        {
            var domain = new PhoneNumberType();

            if (model != null)
            {
                domain.Id   = model.Id;
                domain.Type = model.Type;
            }

            return(domain);
        }
Exemplo n.º 5
0
        public static PhoneNumberTypeModel ToModel(this PhoneNumberType domain)
        {
            var model = new PhoneNumberTypeModel();

            if (domain != null)
            {
                model.Id   = domain.Id;
                model.Type = domain.Type;
            }

            return(model);
        }