public ActionResult _MoneyChange(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    //ajd.ErrorMsg = "下注前須先登入\n請先至會員登入中心進行登入註冊,謝謝";
                    ajd.isTrue = false;
                    throw new Exception("error");
                }
                ProductApiModel pm = new ProductApiModel();

                Product product = new MallRepository().Get(id);
                // List<Product> productAll = new MallRepository().getAll();
                cfgUnit unit = new UnitsRepository().getValid(product.unitSn);

                pm.unit    = unit;
                pm.product = product;
                //pm.producList = productAll.Where(x => x.id < 5).ToList();
                var gold = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == product.unitSn).FirstOrDefault();
                ViewBag.gold   = (gold != null) ? gold.Asset : 0;
                ViewBag.change = (product.Price > ViewBag.gold) ? 0 : 1;
                return(View(pm));
            }
            catch
            {
                //ajd.isTrue = false;
                return(Json(ajd));
            }
        }
        public ActionResult _FishPay(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    //ajd.ErrorMsg = "下注前須先登入\n請先至會員登入中心進行登入註冊,謝謝";
                    ajd.isTrue = false;
                    throw new Exception("error");
                }

                Product         product    = new MallRepository().Get(id);
                List <Product>  productAll = new MallRepository().getAll();
                cfgUnit         unit       = new UnitsRepository().getValid(product.unitSn);
                ProductApiModel pm         = new ProductApiModel();
                pm.unit       = unit;
                pm.product    = product;
                pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList();
                return(View(pm));
            }
            catch
            {
                return(Json(ajd));
            }
        }
        public ActionResult Mall()
        {
            ViewData["cfgUnit"] = new UnitsRepository().getAll();
            List <Product> pd = new MallRepository().getAll();

            return(View(pd));
        }
        public static MvcHtmlString UnitSelect(this HtmlHelper htmlhelper, string name, int?defualValue) //開放、靜態、的擴充方法
        {
            List <cfgUnit>        UnitList = new UnitsRepository().getAllValid();
            List <SelectListItem> sliList  = new List <SelectListItem>();

            sliList.Add(new SelectListItem
            {
                Text  = "請選擇",
                Value = ""
            });
            defualValue = (defualValue.HasValue ? defualValue.Value : 0);
            foreach (var s in UnitList.Where(x => x.sn != 10))
            {
                SelectListItem sli = new SelectListItem
                {
                    Text     = s.name,
                    Value    = s.sn.ToString(),
                    Selected = (s.sn == defualValue.Value ? true : false)
                };
                sliList.Add(sli);
            }



            return(System.Web.Mvc.Html.SelectExtensions.DropDownList(htmlhelper, name, sliList, new { @class = "form-control" }));
        }
        public ActionResult Index()
        {
            ViewData["cfgUnit"] = new UnitsRepository().getAll();
            List <Product> pd = new MallRepository().getAll().ToList();

            ViewData["ProductM"] = new MallRepository().PMenuGetAll();
            return(View(pd));
        }
        public ActionResult _Invoice(int id)
        {
            Product         product = new MallRepository().Get(id);
            cfgUnit         unit    = new UnitsRepository().getValid(product.unitSn);
            ProductApiModel pm      = new ProductApiModel();

            pm.unit    = unit;
            pm.product = product;



            string _Vi             = "ugZbqRhI6x5LGI94";
            string _key            = "CON3KthrvPulsAWQQiQ3jsswLIzxxgQK";
            string MerchantOrderNo = DateTime.Now.Ticks.ToString() + "0" + pm.product.id.ToString();
            var    user            = UserManager.FindById(User.Identity.GetUserId());
            var    tradeInfo       = new TradeInfo()
            {
                MerchantID  = "MS15822085",
                RespondType = "JSON",
                TimeStamp   = DateTime.Now.ToUnixTimeStamp(),
                Version     = "1.5",
                Amt         = (int)pm.product.Price,
                ItemDesc    = pm.product.ProductName,
                //InstFlag="3,6",
                //CreditRed = 0,
                Email           = user.Email,
                EmailModify     = 1,
                LoginType       = 0,
                MerchantOrderNo = MerchantOrderNo,
                TradeLimit      = 180
            };
            var postData     = tradeInfo.ToDictionary();
            var cryptoHelper = new CryptoHelper(_key, _Vi);
            var aesString    = cryptoHelper.GetAesString(postData);

            ViewData["TradeInfo"]   = aesString;
            ViewData["TradeSha"]    = cryptoHelper.GetSha256String(aesString);
            ViewData["Email"]       = tradeInfo.Email;
            ViewBag.TimeStamp       = tradeInfo.TimeStamp;
            ViewBag.MerchantOrderNo = tradeInfo.MerchantOrderNo;
            User_CashReturn re = new User_CashReturn
            {
                userId     = User.Identity.GetUserId(),
                MerchantID = MerchantOrderNo,
                productId  = pm.product.id,
                inpdate    = DateTime.Now,
            };

            new MallRepository().CreateReturnRecord(re);


            //ViewBag.sha256 = getHashSha256("HashKey=CON3KthrvPulsAWQQiQ3jsswLIzxxgQK&Amt="+pm.product.Price+"&MerchantID=MS15822085&MerchantOrderNo="+ time + "&TimeStamp="+ time + "&Version=1.5&HashIV=ugZbqRhI6x5LGI94");



            return(View(pm));
        }
        /// <summary>
        /// Initializes the view model.
        /// </summary>
        public void Init(InventoriesRepository inventoriesRepository,
                         UnitsRepository unitsRepository)
        {
            InventoriesSelectListItems = new SelectList(
                inventoriesRepository.GetAll(),
                "ProductCode", "ProductCode");

            UnitsSelectListItems = new SelectList(
                unitsRepository.GetList(), "Id", "Name");
        }
Example #8
0
 public InventoriesController(InventoriesRepository inventoriesRepository, InventoryInputsRepository inventoryInputsRepository,
                              ProductsRepository productsRepository, InventoryOutputsRepository inventoryOutputsRepository,
                              ProductModificationsRepository productModificationsRepository, UnitsRepository unitsRepository)
 {
     _inventoriesRepository          = inventoriesRepository;
     _inventoryInputsRepository      = inventoryInputsRepository;
     _productsRepository             = productsRepository;
     _inventoryOutputsRepository     = inventoryOutputsRepository;
     _productModificationsRepository = productModificationsRepository;
     _unitsRepository = unitsRepository;
 }
Example #9
0
        public override void TestInitialize()
        {
            base.TestInitialize();
            units    = new UnitsRepository();
            measures = new MeasuresRepository();
            data     = GetRandom.Object <MeasureData>();
            var m = new Measure(data);

            measures.Add(m).GetAwaiter();
            AddRandomMeasures();
            obj = new TestClass(units, measures);
        }
        /*public ActionResult Pay()
         * {
         *  return View();
         * }*/

        public ActionResult Pay(int id)
        {
            Product         product = new MallRepository().Get(id);
            cfgUnit         unit    = new UnitsRepository().getValid(product.unitSn);
            ProductApiModel pm      = new ProductApiModel();

            pm.unit    = unit;
            pm.product = product;


            return(View(pm));
        }
        public ActionResult Index()
        {
            List <PProductViewModel> pam = new List <PProductViewModel>();

            ViewData["cfgUnit"] = new UnitsRepository().getAll();
            List <Product>      pd  = new MallRepository().getAll().ToList();
            List <Preferential> pft = new PreferentialRepository().getAllvaild();

            foreach (var p in pd)
            {
                PProductViewModel pm = new PProductViewModel();
                pm.id             = p.id;
                pm.image          = p.image;
                pm.inpdate        = p.inpdate;
                pm.Price          = p.Price;
                pm.ProductContent = p.ProductContent;
                pm.transform      = p.transform;
                pm.type           = p.type;
                pm.unitSn         = p.unitSn;
                pm.valid          = p.valid;
                pm.ProductName    = p.ProductName;
                pm.createDate     = p.createDate;



                if (p.type == 1 || p.type == 2)
                {
                    if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                    {
                        pm.offer = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                        pm.Pname = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().Pname;
                    }

                    foreach (var pt in pft.Where(x => x.offerModel == 3))
                    {
                        if (pt.productId == p.id)
                        {
                            pm.offer = pt.offer;
                            pm.Pname = pt.Pname;
                        }
                    }
                }

                pam.Add(pm);
            }
            //new MailServiceMailgun().ChangeSend("熊i猜兌獎通知信", "test","*****@*****.**", "");
            ViewData["ProductM"] = new MallRepository().PMenuGetAll();
            return(View(pam));
        }
 /// <summary>
 /// Initializes the view model.
 /// </summary>
 public void Init(ProductTypesRepository productTypesRepository,
                  SuppliersRepository suppliersRepository,
                  UnitsRepository unitsRepository,
                  string userId)
 {
     ProductTypesSelectListItems = new SelectList(
         productTypesRepository.GetList(),
         "Id", "Name");
     SuppliersSelectListItems = new SelectList(
         suppliersRepository.GetList(),
         "Id", "Name");
     UnitsSelectListItems = new SelectList(
         unitsRepository.GetList(),
         "Id", "Name", "Quantity");
 }
Example #13
0
        public override void TestInitialize()
        {
            base.TestInitialize();
            var t = new TermRepository();
            var f = new FactorRepository();

            _units    = new UnitsRepository();
            _measures = new MeasuresRepository();
            _data     = GetRandom.Object <MeasureData>();
            var m = new Measure(_data);

            _measures.Add(m).GetAwaiter();
            AddRandomMeasures();
            obj = new TestClass(_units, _measures, t, f);
        }
 public ProductsController(ProductsRepository productsRepository,
                           InventoriesRepository inventoriesRepository,
                           SuppliersRepository suppliersRepository,
                           ProductTypesRepository productTypesRepository,
                           UnitsRepository unitsRepository,
                           InventoryInputsRepository inventoryInputsRepository,
                           ProductModificationsRepository productModificationsRepository)
 {
     _productsRepository             = productsRepository;
     _inventoriesRepository          = inventoriesRepository;
     _productTypesRepository         = productTypesRepository;
     _suppliersRepository            = suppliersRepository;
     _unitsRepository                = unitsRepository;
     _inventoryInputsRepository      = inventoryInputsRepository;
     _productModificationsRepository = productModificationsRepository;
 }
        public void Arrange()
        {
            unit1 = new Unit {
                People = new Collection <Person>()
            };
            unit2 = new Unit {
                People = new Collection <Person>()
            };

            this.person = new Person();
            unit1.People.Add(person);

            context = new FakeUnitServiceContext();
            this.context.Units.Add(unit1);
            this.context.Units.Add(unit2);

            repository = new UnitsRepository(this.context);

            this.Act();
        }
Example #16
0
 private void initUnitLists()
 {
     unitsRepository = GameObject.Find("Units").GetComponent <UnitsRepository>();
     unitsRepository.initialize();
     unitPresenter = GameObject.Find("Units").GetComponent <UnitPresenter>();
 }
Example #17
0
 /// <summary>
 /// Initializes the view model.
 /// </summary>
 public void Init(UnitsRepository unitsRepository)
 {
     UnitsSelectListItems = new SelectList(
         unitsRepository.GetList(),
         "Id", "Name", "Quantity");
 }
        public async Task <ActionResult> _MallChange(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                ProductApiModel pm = new ProductApiModel();

                Product product = new MallRepository().Get(id);
                // List<Product> productAll = new MallRepository().getAll();
                cfgUnit unit = new UnitsRepository().getValid(product.unitSn);

                pm.unit    = unit;
                pm.product = product;
                //pm.producList = productAll.Where(x => x.id < 5).ToList();
                int offer = 100;

                List <Preferential> pft = new PreferentialRepository().getAllvaild();
                ViewBag.offer = 100;
                if (pft != null)
                {
                    if (pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault() != null)
                    {
                        ViewBag.offer = pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                        offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == null).FirstOrDefault().offer;
                    }

                    foreach (var pt in pft.Where(x => x.offerModel == 3))
                    {
                        if (pt.productId == id)
                        {
                            ViewBag.offer = pt.offer;
                            offer         = (int)pft.Where(x => x.offerModel == 3 && x.productId == id).FirstOrDefault().offer;
                        }
                    }
                }

                var gold = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()).Where(x => x.unitSn == product.unitSn).FirstOrDefault();
                ViewBag.gold   = (gold != null) ? gold.Asset : 0;
                ViewBag.change = (product.Price * offer / 100 > ViewBag.gold) ? 0 : 1;



                return(View(pm));
            }
            catch
            {
                //ajd.isTrue = false;
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }
Example #19
0
 public UnitsRepositoryTests()
 {
     dbConfiguration = new DatabaseConfiguration();
     session         = dbConfiguration.GetSession();
     unitsRepository = new UnitsRepository(session);
 }
 public UnitsController(UnitsRepository unitsRepository)
 {
     _unitsRepository = unitsRepository;
 }
 public UnitsLogic()
 {
     _unitsRepository = new UnitsRepository();
 }
        public ActionResult _FishPay(int id)
        {
            aJaxDto ajd = new aJaxDto();

            try
            {
                if (User.Identity.GetUserId() == null)
                {
                    ajd.ErrorMsg = "登入後才可以購買";
                    ajd.Title    = "未登入!";
                    ajd.isTrue   = true;
                    throw new Exception("error");
                }
                var user = UserManager.FindById(User.Identity.GetUserId());
                if (!user.EmailConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "Email尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }
                if (!user.PhoneNumberConfirmed)
                {
                    ajd.ErrorMsg = "請先至會員中心進行驗證,謝謝";
                    ajd.Title    = "手機尚未驗證!";
                    ajd.isTrue   = false;
                    throw new Exception("error");
                }

                //var pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());

                //普通首儲

                /*if (pr == null)
                 * {
                 *  var prm = new PreferentialRecords {
                 *      UserId = User.Identity.GetUserId(),
                 *      Count = 1,
                 *      inpdate = DateTime.Now,
                 *      PreferentialID = 1
                 *  };
                 *
                 *  new PreferentialRepository().PRecordsCreate(prm);
                 *  pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                 * }*/
                var pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);
                //2倍首儲
                if (pr.Count() == 0)
                {
                    var m = new MallRepository().getAll().Where(x => x.unitSn == 3 && x.type == 3).ToList();
                    foreach (var md in m)
                    {
                        var prm = new PreferentialRecords
                        {
                            UserId         = User.Identity.GetUserId(),
                            Count          = 1,
                            inpdate        = DateTime.Now,
                            PreferentialID = 5,
                            productID      = md.id
                        };

                        new PreferentialRepository().PRecordsCreate(prm);
                        //pr = new PreferentialRepository().getPRecords(User.Identity.GetUserId());
                    }
                }
                pr = new PreferentialRepository().getPRecordsAll(User.Identity.GetUserId()).Where(x => x.PreferentialID == 5);



                Product         product    = new MallRepository().Get(id);
                List <Product>  productAll = new MallRepository().getAll();
                cfgUnit         unit       = new UnitsRepository().getValid(product.unitSn);
                ProductApiModel pm         = new ProductApiModel();
                pm.unit       = unit;
                pm.product    = product;
                pm.producList = productAll.Where(x => x.unitSn == 3 && x.type == 3).ToList();

                List <int> fta = new List <int>();
                foreach (var p in pr)
                {
                    if (p.Count != 0)
                    {
                        fta.Add(1);
                    }
                    else
                    {
                        fta.Add(0);
                    }
                }
                pm.firstTypeArray = fta;
                if (pr.Where(x => x.Count != 0).Count() != 0)
                {
                    pm.firstType = 1;
                }
                else
                {
                    pm.firstType = 0;
                }
                //pm.firstType = (pr.Count != 0) ? 1 : 0;
                pm.preferential = new PreferentialRepository().getpreferential(1);
                return(View(pm));
            }
            catch
            {
                return(Json(ajd, JsonRequestBehavior.AllowGet));
            }
        }