Ejemplo n.º 1
0
        public void GetOfferForDevice_Test()
        {
            PersistantDevice persistantDevice = new PersistantDevice()
            {
                Clubcard = "222222222",
                EmailId = "*****@*****.**",
                GcmToken = "TR000001",
                Id = "1234555",
                Mobile = "9999999999",
                Name = "Test"
            };

            PersistantOffer offer = new PersistantOffer()
            {
                Name = "test Offer",
                Description = "Test Offer Description",
                ImagePath = "Image test path",
                OfferCode = "Offer Code"
            };
            List<PersistantOffer> lstPersistantOffer = new List<PersistantOffer>();
            lstPersistantOffer.Add(offer);

            _persist.Setup(r => r.GetDeviceDetailsByDeviceId(It.IsAny<string>())).Returns(persistantDevice);
            _persist.Setup(r => r.GetOffers(It.IsAny<string>(), It.IsAny<string>())).Returns(lstPersistantOffer);
            IP2PBusinessLogic business = new P2PBusinessLogic(_persist.Object);
            var result = business.GetOffers("test device id","test store id",true);
            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        public PersistantDevice GetDeviceDetailsByDeviceId(string deviceId)
        {
            try
            {
                GetConnection();

                SqlCommand cmd = new SqlCommand("Select * from device where id = @id", conn);

                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@id", deviceId);
                PersistantDevice _device = null;

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        _device = new PersistantDevice()
                        {
                            Id = reader["id"].ToString(),
                            Name = reader["Name"].ToString(),
                            GcmToken = reader["GcmToken"].ToString(),
                            Clubcard = reader["Clubcard"].ToString(),
                            EmailId = reader["EmailId"].ToString(),
                            Mobile = reader["Mobile"].ToString()
                        };
                    }
                }
                return _device;

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 3
0
        public bool UpdateDeviceDetails(PersistantDevice device)
        {
            try
            {
                GetConnection();

                SqlCommand cmd = new SqlCommand("update Device set EmailId = @EmailId,Name = @Name,GcmToken = @GcmToken,Clubcard = @Clubcard,Mobile = @Mobile where id = @id", conn);

                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@id", device.Id);
                cmd.Parameters.AddWithValue("@EmailId", device.EmailId);
                cmd.Parameters.AddWithValue("@Name", device.Name);
                cmd.Parameters.AddWithValue("@GcmToken", device.GcmToken);
                cmd.Parameters.AddWithValue("@Clubcard", device.Clubcard);
                cmd.Parameters.AddWithValue("@Mobile", device.Mobile);

                cmd.ExecuteNonQuery();

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                conn.Close();
            }
            return true;
        }
Ejemplo n.º 4
0
        public bool RegisterDevice(PersistantDevice device)
        {
            try
            {
                GetConnection();

                SqlCommand cmd = new SqlCommand("RegisterUser",conn);

                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id",device.Id);
                cmd.Parameters.AddWithValue("@EmailId", device.EmailId);
                cmd.Parameters.AddWithValue("@Name", device.Name);
                cmd.Parameters.AddWithValue("@GcmToken", device.GcmToken);
                cmd.Parameters.AddWithValue("@Clubcard", device.Clubcard);
                cmd.Parameters.AddWithValue("@Mobile", device.Mobile);

                cmd.ExecuteNonQuery();

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                conn.Close();
            }

            return true;
        }
Ejemplo n.º 5
0
        public bool RegisterDevice(PersistantDevice device)
        {
            try
            {
                GetConnection();

                SqlCommand cmd = new SqlCommand("insert into Device values(@id,@EmailId,@Name,@GcmToken,@Clubcard,@Mobile);", _conn);

                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.AddWithValue("@id",device.Id);
                cmd.Parameters.AddWithValue("@EmailId", device.EmailId);
                cmd.Parameters.AddWithValue("@Name", device.Name);
                cmd.Parameters.AddWithValue("@GcmToken", device.GcmToken);
                cmd.Parameters.AddWithValue("@Clubcard", device.Clubcard);
                cmd.Parameters.AddWithValue("@Mobile", device.Mobile);

                cmd.ExecuteNonQuery();

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                _conn.Close();
            }

            return true;
        }
Ejemplo n.º 6
0
        public void UpdateDevice_Test()
        {
            Device _device = new Device()
            {
                Name = "Test Name",
                Id = "Device ID",
                GcmToken = "Test GCM Token",
                Mobile = "9999999999",
                EmailId = "*****@*****.**",
                Clubcard = "2345677765"
            };

            PersistantDevice persistantDevice = new PersistantDevice()
            {
                Clubcard = "222222222",
                EmailId = "*****@*****.**",
                GcmToken = "TR000001",
                Id = "1234555",
                Mobile = "9999999999",
                Name = "Test"
            };

            _persist.Setup(r => r.GetDeviceDetailsByDeviceId(It.IsAny<string>())).Returns(persistantDevice);
            _persist.Setup(r => r.RegisterDevice(It.IsAny<PersistantDevice>())).Returns(true);
            IP2PBusinessLogic business = new P2PBusinessLogic(_persist.Object);
            var result = business.RegisterDevice(_device);
            Assert.IsTrue(result);
        }