public void PackageDiscounDualfuelBroadbandTypeBasicShouldReturn5PercentangeTest()
        {
            Mock <IPackageService> packageServiceMock = new Mock <IPackageService>();

            packageServiceMock.Setup(x => x.GetPackage(It.IsAny <string>())).Returns(GetBasicFuelTypePackage());

            _packageDiscount = new PackageDiscount(packageServiceMock.Object);
            var result = _packageDiscount.GetDiscount(It.IsAny <string>());

            Assert.AreEqual(result, 5);
        }
        public void PackageDiscounOnlyElectricityBroadbandTypeHighSpeedShouldReturn5PercentangeTest()
        {
            Mock <IPackageService> packageServiceMock = new Mock <IPackageService>();

            packageServiceMock.Setup(x => x.GetPackage(It.IsAny <string>())).Returns(GetHighSpeedOnlyElectricityPackage());

            _packageDiscount = new PackageDiscount(packageServiceMock.Object);
            var result = _packageDiscount.GetDiscount(It.IsAny <string>());

            Assert.AreEqual(result, 5);
        }
예제 #3
0
        public DataTable SavePackageDiscounts(PackageDiscount dc)
        {
            DataTable     dt   = new DataTable();
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "InsUpdDelPackageDiscounts";

            SqlParameter Id = new SqlParameter();

            Id.ParameterName = "@Id";
            Id.SqlDbType     = SqlDbType.Int;
            Id.Value         = Convert.ToString(dc.Id);
            cmd.Parameters.Add(Id);

            SqlParameter Code = new SqlParameter();

            Code.ParameterName = "@Code";
            Code.SqlDbType     = SqlDbType.VarChar;
            Code.Value         = Convert.ToString(dc.Code);
            cmd.Parameters.Add(Code);

            SqlParameter Title = new SqlParameter();

            Title.ParameterName = "@PackageId";
            Title.SqlDbType     = SqlDbType.Int;
            Title.Value         = Convert.ToString(dc.PackageId);
            cmd.Parameters.Add(Title);

            SqlParameter Description = new SqlParameter();

            Description.ParameterName = "@TypeId";
            Description.SqlDbType     = SqlDbType.Int;
            Description.Value         = Convert.ToString(dc.TypeId);
            cmd.Parameters.Add(Description);

            SqlParameter Type = new SqlParameter();

            Type.ParameterName = "@ApplyOn";
            Type.SqlDbType     = SqlDbType.Int;
            Type.Value         = Convert.ToString(dc.ApplyOn);
            cmd.Parameters.Add(Type);

            SqlParameter Category = new SqlParameter();

            Category.ParameterName = "@Value";
            Category.SqlDbType     = SqlDbType.Int;
            Category.Value         = Convert.ToString(dc.Value);
            cmd.Parameters.Add(Category);

            SqlParameter ApplyAs = new SqlParameter();

            ApplyAs.ParameterName = "@UnitTypeId";
            ApplyAs.SqlDbType     = SqlDbType.Int;
            ApplyAs.Value         = Convert.ToString(dc.UnitTypeId);
            cmd.Parameters.Add(ApplyAs);

            SqlParameter Value = new SqlParameter();

            Value.ParameterName = "@UnitId";
            Value.SqlDbType     = SqlDbType.Int;
            Value.Value         = Convert.ToString(dc.UnitId);
            cmd.Parameters.Add(Value);

            SqlParameter EffectiveDate = new SqlParameter();

            EffectiveDate.ParameterName = "@EffectiveDate";
            EffectiveDate.SqlDbType     = SqlDbType.DateTime;
            EffectiveDate.Value         = Convert.ToString(dc.EffectiveDate);
            cmd.Parameters.Add(EffectiveDate);

            SqlParameter ExpiryDate = new SqlParameter();

            ExpiryDate.ParameterName = "@ExpiryDate";
            ExpiryDate.SqlDbType     = SqlDbType.DateTime;
            ExpiryDate.Value         = Convert.ToString(dc.ExpiryDate);
            cmd.Parameters.Add(ExpiryDate);

            SqlParameter ChargeTy = new SqlParameter();

            ChargeTy.ParameterName = "@DiscountTypeId";
            ChargeTy.SqlDbType     = SqlDbType.Int;
            ChargeTy.Value         = Convert.ToString(dc.DiscountTypeId);
            cmd.Parameters.Add(ChargeTy);


            SqlParameter Flag = new SqlParameter();

            Flag.ParameterName = "@Flag ";
            Flag.SqlDbType     = SqlDbType.VarChar;
            Flag.Value         = Convert.ToString(dc.flag);
            cmd.Parameters.Add(Flag);


            SqlDataAdapter db = new SqlDataAdapter(cmd);

            db.Fill(dt);
            return(dt);
        }