Example #1
0
        public JsonResult UploadImage(IFormFile photo, string CPhone)
        {
            擺腹BuyFoodContext db = new 擺腹BuyFoodContext();

            TMember mem新增圖片 = (from n in db.TMembers
                               where n.CPhone == CPhone
                               select n).FirstOrDefault();

            if (photo != null)
            {
                string photoname = Guid.NewGuid().ToString() + ".jpg";

                using (var MemberPhoto = new FileStream(iv_host.WebRootPath + @"\MemberPhoto\" + photoname, FileMode.Create))
                {
                    photo.CopyTo(MemberPhoto);
                }

                mem新增圖片.CPicture = @"/MemberPhoto/" + photoname;
                db.SaveChanges();
                return(Json(new { result = true }));
            }
            else
            {
                mem新增圖片.CPicture = @"/MemberPhoto/無人頭.jpg";
                db.SaveChanges();
            }

            return(Json(new { result = false }));
        }
Example #2
0
        public IActionResult Insert([FromBody] CrudViewModel <TMemberConfirmContact> payload)
        {
            TMemberConfirmContact memberConfirmContact = payload.value;

            memberConfirmContact.registraiondateMemberConfirm = DateTime.Now;

            _context.TMemberConfirmContact.Add(memberConfirmContact);
            _context.SaveChanges();


            bool activeMember = IsCheckConfirm(memberConfirmContact.memberID);

            if (activeMember)
            {
                TMember member = _context.TMember
                                 .Where(x => x.memberID == memberConfirmContact.memberID)
                                 .FirstOrDefault();

                member.statusMember = true;

                _context.TMember.Update(member);
                _context.SaveChanges();
            }

            return(Ok(memberConfirmContact));
        }
Example #3
0
        public void FindById_ContextCache()
        {
            ConsoleTitleUtil.ShowTestTitle("FindById_ContextCache");

            //复杂关联find
            TArticle art = TArticle.findById(1);

            Console.WriteLine("article 1 title is : " + art.Title);
            Assert.AreEqual("狂人日记", art.Title);

            //一级缓存
            TMember member = TMember.findById(13);

            Console.WriteLine("member 13 name is : " + member.Name);
            Assert.AreEqual("袁世凯", member.Name);

            TCat cat = TCat.findById(8);

            Console.WriteLine("cat 8 name is " + cat.Name);
            Assert.AreEqual("武侠小说", cat.Name);

            TBoard board = TBoard.findById(9);

            Console.WriteLine("board 9 name is : " + board.Name);
            Assert.AreEqual("board_互联网络", board.Name);
        }
Example #4
0
        public void FindCondition_WithEqual()
        {
            TArticle art = new TArticle();

            art.Member     = TMember.findById(8);
            art.Cat        = TCat.findById(7);
            art.Board      = TBoard.findById(3);
            art.Author     = "163羽化";
            art.Title      = "myurl=www.163.com";
            art.CreateTime = DateTime.Now;
            art.ChannelId  = 4;
            art.IsDelete   = 0;
            art.OrderId    = 15;

            art.insert();

            IList <TArticle> articles = TArticle.find("Title=:t").set("t", art.Title).list();

            Assert.AreEqual(1, articles.Count);

            logger.Info("===========================================================================");
            IList <TArticle> articles2 = TArticle.find("Title='" + art.Title + "'").list();

            Assert.AreEqual(1, articles2.Count);
        }
 public OrderDetailsViewModel()
 {
     iv_orderDetails = new TOrderDetail();
     iv_member       = new TMember();
     iv_orderStatus  = new TOrderStatus();
     iv_product      = new TProduct();
 }
Example #6
0
        public IActionResult MemberCenter()
        {
            ViewBag.LOCALWEBSITES = CDictionary.LOCAL_WEBSITES;
            if (!string.IsNullOrEmpty(HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERNAME)))
            {
                ViewBag.userName  = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERNAME);
                ViewBag.userPhoto = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERPHOTO);
                ViewBag.memberID  = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERID);
                ViewBag.facebook  = string.IsNullOrEmpty(HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_FACEBOOK)) ? "0" : "1";
                擺腹BuyFoodContext dbcontext = new 擺腹BuyFoodContext();
                TMember          data      = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == int.Parse(HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERID)));

                if (TempData[CDictionary.REDIRECT_FROM_WHERE] != null)
                {
                    // 1:儲值, 2:套餐
                    string goWhere = TempData[CDictionary.REDIRECT_FROM_WHERE].ToString();
                    return(View(new MemberCenterViewModel(data, goWhere)));
                }
                return(View(new MemberCenterViewModel(data, "0")));
            }

            else
            {
                return(RedirectToAction("登入", "HomePage"));
            }
        }
 public OrderDetailsViewModel(TOrderDetail orderDetail, TMember member, TOrderStatus orderStatus, TProduct product)
 {
     orderDetail = iv_orderDetails;
     member      = iv_member;
     orderStatus = iv_orderStatus;
     product     = iv_product;
 }
Example #8
0
 public ValueCache(object member, IList <TValue> attributes, Func <object, object> getter = null)
 {
     Member = (TMember)member;
     Getter = getter;
     _list  = attributes;
     Count  = _list?.Count ?? 0;
 }
Example #9
0
        public IActionResult Edit(MemberManagementViewModel p)
        {
            if (p.image != null)
            {
                string photoName = Guid.NewGuid().ToString() + ".jpg";
                using (var photo = new FileStream(iv_host.WebRootPath + @"\MemberPhoto\" + photoName, FileMode.Create))
                {
                    p.image.CopyTo(photo);
                }
                p.CPicture = @"/MemberPhoto/" + photoName;
            }


            if (p != null)
            {
                TMember table = db.TMembers.FirstOrDefault(t => t.CMemberId == p.CMemberId);
                if (table != null)
                {
                    table.CName      = p.CName;
                    table.CEmail     = p.CEmail;
                    table.CPhone     = p.CPhone;
                    table.CGender    = p.CGender;
                    table.CAddress   = p.CAddress;
                    table.CBlackList = p.CBlackList;
                    table.CAge       = p.CAge;
                    table.CPicture   = p.CPicture == null? table.CPicture:p.CPicture; //←要存改照片的話就解開
                    //table.CRegisteredTime = DateTime.Now; //加註冊時間進資料庫
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("List"));
        }
Example #10
0
 public yuOrderViewModel(TOrder p, TCupon pCupon, TMember pMember, TOrderStatus pOrderStatus)
 {
     iv_Order     = p;
     CCupon       = pCupon;
     CMember      = pMember;
     COrderStatus = pOrderStatus;
 }
Example #11
0
        //------------------------- Insert -------------------------

        public void InsertArticle()
        {
            ConsoleTitleUtil.ShowTestTitle("InsertArticle");

            TArticle art = new TArticle();

            art.Member     = TMember.findById(13);
            art.Cat        = TCat.findById(8);
            art.Board      = TBoard.findById(9);
            art.Author     = "54鲁迅";
            art.Title      = "狂人日记";
            art.CreateTime = DateTime.Now;
            art.ChannelId  = 18;
            art.IsDelete   = 0;
            art.OrderId    = 5;
            art.insert();
            int id = art.Id;

            art.Member     = TMember.findById(2);
            art.Cat        = TCat.findById(10);
            art.Board      = TBoard.findById(11);
            art.Author     = "周做人";
            art.Title      = "论雷锋大的倒掉";
            art.CreateTime = DateTime.Now;
            art.ChannelId  = 12;
            art.IsDelete   = 0;
            art.OrderId    = 8;
            art.insert();
            id = id + 1;
            Assert.AreEqual(id, art.Id);

            art.Member     = TMember.findById(7);
            art.Cat        = TCat.findById(4);
            art.Board      = TBoard.findById(4);
            art.Author     = "嵇康";
            art.Title      = "与善举员绝交数";
            art.CreateTime = DateTime.Now;
            art.ChannelId  = 4;
            art.IsDelete   = 0;
            art.OrderId    = 9;
            art.insert();
            id = id + 1;
            Assert.AreEqual(id, art.Id);

            art.Member     = TMember.findById(8);
            art.Cat        = TCat.findById(7);
            art.Board      = TBoard.findById(3);
            art.Author     = "羽化";
            art.Title      = "许三管买血迹";
            art.CreateTime = DateTime.Now;
            art.ChannelId  = 4;
            art.IsDelete   = 0;
            art.OrderId    = 15;
            art.insert();
            id = id + 1;
            Assert.AreEqual(id, art.Id);

            Console.WriteLine("添加 article 成功!");
        }
Example #12
0
        public IActionResult Edit([FromBody] CrudViewModel <TMember> payload)
        {
            TMember member = payload.value;

            _context.TMember.Update(member);
            _context.SaveChanges();
            return(Ok(member));
        }
        public void orderCancel(int?id)
        {
            if (id != null)
            {
                TOrder         l_order被修改  = db.TOrders.FirstOrDefault(n => n.COrderId == id);
                TMember        l_member被修改 = db.TMembers.FirstOrDefault(n => n.CMemberId == l_order被修改.CMemberId);
                TCupon         l_cupon被修改  = db.TCupons.FirstOrDefault(n => n.CCuponId == l_order被修改.CCuponId);
                TCuponCategory p折扣金額       = db.TCuponCategories.FirstOrDefault(n => n.CCuponCategoryId == l_cupon被修改.CCuponCategoryId);


                IEnumerable <TOrderDetail> table = null;
                table = db.TOrderDetails.Where(n => n.COrderId == id);

                List <TOrderDetail> list = new List <TOrderDetail>();
                foreach (var item in table)
                {
                    list.Add(item);
                }
                decimal p總價 = 0;
                decimal p價格 = 0;
                int     p數量 = 0;
                int     pID = 0;
                for (int i = 0; i < list.Count(); i++)
                {
                    //消費金額
                    p價格  = list[i].CPriceAtTheTime.Value;
                    p數量  = list[i].CQuantity.Value;
                    p總價 += (p價格 * p數量);

                    //產品庫存
                    pID = list[i].CProductId;
                    TProduct l_product被修改 = db.TProducts.FirstOrDefault(n => n.CProductId == pID);
                    l_product被修改.CQuantity += p數量;
                }

                if (l_order被修改.CPayTypeId.Value == 1)
                {
                    //無折扣
                    if (l_order被修改.CCuponId.Value == 1)
                    {
                        l_order被修改.COrderStatusId = 3;
                        l_member被修改.CDeposit     += p總價;
                    }
                    //有折扣
                    else
                    {
                        l_order被修改.COrderStatusId = 3;
                        l_member被修改.CDeposit     += (p總價 - p折扣金額.CCutPrice.Value);
                        l_cupon被修改.CBeUsed        = 0;
                    }
                }
                else
                {
                    l_order被修改.COrderStatusId = 3;
                }
                db.SaveChanges();
            }
        }
Example #14
0
        public JsonResult saveProfile([FromBody] TMember member)
        {
            擺腹BuyFoodContext dbcontext = new 擺腹BuyFoodContext();
            TMember          data      = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == member.CMemberId);

            data.CName = member.CName;
            dbcontext.SaveChanges();
            return(Json(data));
        }
Example #15
0
        public IActionResult Remove([FromBody] CrudViewModel <TMember> payload)
        {
            TMember member = _context.TMember
                             .Where(x => x.memberID == (int)payload.key)
                             .FirstOrDefault();

            _context.TMember.Remove(member);
            _context.SaveChanges();
            return(Ok(member));
        }
Example #16
0
        public JsonResult QRcode(string id)
        {
            擺腹BuyFoodContext dbcontext    = new 擺腹BuyFoodContext();
            TMember          targetMember = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == int.Parse(id));
            string           head         = $"<h1>推薦碼 : {targetMember.CReferrerCode}</h1>";
            string           contenxt     = CDictionary.LOCAL_WEBSITES + $"/Customer/Create?id={targetMember.CReferrerCode}";
            List <string>    data         = new List <string>();

            data.Add(head);
            data.Add(contenxt);
            return(Json(data));
        }
Example #17
0
 public IActionResult Edit(int?id)
 {
     if (id != null)
     {
         TMember table = db.TMembers.FirstOrDefault(a => a.CMemberId == id);
         if (table != null)
         {
             return(View(new MemberManagementViewModel(table)));
         }
     }
     return(RedirectToAction("List"));
 }
Example #18
0
        public void InsertMember()
        {
            ConsoleTitleUtil.ShowTestTitle("InsertMember");

            TMember member = new TMember();

            member.Name = "张三";
            member.insert();

            member.Name = "屈原";
            member.insert();

            member.Name = "李白";
            member.insert();

            member.Name = "嵇康";
            member.insert();

            member.Name = "庄子";
            member.insert();

            member.Name = "杜甫";
            member.insert();

            member.Name = "苏轼";
            member.insert();

            member.Name = "李世民";
            member.insert();

            member.Name = "诸葛亮";
            member.insert();

            member.Name = "曹操";
            member.insert();

            member.Name = "司马迁";
            member.insert();

            member.Name = "孙中山";
            member.insert();

            member.Name = "袁世凯";
            member.insert();

            member.Name = "毛泽东";
            member.insert();

            Console.WriteLine("添加 member 成功!");
        }
Example #19
0
        public IActionResult memberConfirm()
        {
            string memberOpenID = HttpContext.Request.Query["ID"];

            擺腹BuyFoodContext db = new 擺腹BuyFoodContext();

            TMember openMember = (from n in db.TMembers
                                  where n.CMemberId == int.Parse(memberOpenID)
                                  select n).FirstOrDefault();

            openMember.COpenMember = 1;
            db.SaveChanges();

            HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERNAME, openMember.CName);
            HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERPHOTO, openMember.CPicture);
            HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERID, openMember.CMemberId.ToString());

            return(Redirect("~/HomePage/Home"));
        }
Example #20
0
        public string savePassword([FromBody] changePassword data)
        {
            擺腹BuyFoodContext dbcontext    = new 擺腹BuyFoodContext();
            TMember          reviseTarget = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == int.Parse(data.memberID));

            ShareFunction sf           = new ShareFunction();
            SHA1          sha1         = SHA1.Create();
            string        SHAoPassword = sf.GetHash(sha1, data.oPassword);
            //string SHAoPassword = data.oPassword;
            string SHAnPassword = sf.GetHash(sha1, data.nPassword);

            if (SHAoPassword != reviseTarget.CPassword)
            {
                return("1");
            }
            reviseTarget.CPassword = SHAnPassword;
            dbcontext.SaveChanges();
            return("0");
        }
Example #21
0
        public bool changefreeze(int?id)
        {
            TMember l_凍結修改 = db.TMembers.FirstOrDefault(n => n.CMemberId == id);
            bool    狀態     = false;

            if (l_凍結修改 != null)
            {
                if (l_凍結修改.CFreezeCount == 4)
                {
                    l_凍結修改.CFreezeCount = 0;
                }
                else
                {
                    l_凍結修改.CFreezeCount = 4;
                    狀態 = true;
                }
            }
            db.SaveChanges();
            return(狀態);
        }
Example #22
0
        public bool changeblacklist(int?id)
        {
            TMember l_黑名單修改 = db.TMembers.FirstOrDefault(n => n.CMemberId == id);
            bool    狀態      = false;

            if (l_黑名單修改 != null)
            {
                if (l_黑名單修改.CBlackList == 1)
                {
                    l_黑名單修改.CBlackList = 0;
                }
                else
                {
                    l_黑名單修改.CBlackList = 1;
                    狀態 = true;
                }
            }
            db.SaveChanges();
            return(狀態);
        }
Example #23
0
        public JsonResult UploadOneFile(IFormFile photo)
        {
            string memberID = HttpContext.Session.GetString(CDictionary.CURRENT_LOGINED_USERID);

            if (!string.IsNullOrEmpty(memberID) && photo.Length > 0)
            {
                string photoName = Guid.NewGuid().ToString() + ".jpg";
                string photoPath = iv_host.WebRootPath + @"\MemberPhoto\" + photoName;
                using (
                    var addphoto = new FileStream(photoPath, FileMode.Create))
                {
                    photo.CopyTo(addphoto);
                }
                擺腹BuyFoodContext dbcontext = new 擺腹BuyFoodContext();
                TMember          target    = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == int.Parse(memberID));
                target.CPicture = @"/MemberPhoto/" + photoName;
                dbcontext.SaveChanges();
                HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERPHOTO, target.CPicture);

                return(Json(new { result = "1", msg = "上傳成功", src = target.CPicture }));
            }
            return(Json(new { result = "0", msg = "上傳失敗" }));
        }
Example #24
0
        public JsonResult forgetMemberCheck([FromBody] CForgetPasswordViewModel forgetPwdMember)
        {
            擺腹BuyFoodContext db = new 擺腹BuyFoodContext();
            var check信箱         = from n in db.TMembers
                                  select n.CEmail;

            if (check信箱.Any(n => n == forgetPwdMember.CEmail) == true)
            {
                TMember checkPhone = (from n in db.TMembers
                                      where n.CEmail == forgetPwdMember.CEmail
                                      select n).FirstOrDefault();

                if (checkPhone.CPhone == forgetPwdMember.CPhone)
                {
                    SHA1   sha1           = SHA1.Create();
                    string RandomPwd      = shareFun.產生亂數(16);
                    string ReplacementPwd = shareFun.GetHash(sha1, RandomPwd);
                    checkPhone.CPassword = ReplacementPwd;
                    db.SaveChanges();

                    string val信件內容 = "您的密碼已被修改成 : " + RandomPwd + " , 請登入後自行修改密碼";

                    shareFun.sendGrid(checkPhone.CEmail, checkPhone.CName, "BuyFood帳號開通認證信", val信件內容);


                    return(Json("EditSuccess"));
                }
                else
                {
                    return(Json("wrongPhone"));
                }
            }
            else
            {
                return(Json("noEmail"));
            }
        }
Example #25
0
        public void InsertMember()
        {
            ConsoleTitleUtil.ShowTestTitle( "InsertMember" );

            TMember member = new TMember();

            member.Name = "张三";
            db.insert( member );

            member.Name = "屈原";
            db.insert( member );

            member.Name = "李白";
            db.insert( member );

            member.Name = "嵇康";
            db.insert( member );

            member.Name = "庄子";
            db.insert( member );

            member.Name = "杜甫";
            db.insert( member );

            member.Name = "苏轼";
            db.insert( member );

            member.Name = "李世民";
            db.insert( member );

            member.Name = "诸葛亮";
            db.insert( member );

            member.Name = "曹操";
            db.insert( member );

            member.Name = "司马迁";
            db.insert( member );

            member.Name = "孙中山";
            db.insert( member );

            member.Name = "袁世凯";
            db.insert( member );

            member.Name = "毛泽东";
            db.insert( member );

            Console.WriteLine( "添加 member 成功!" );
        }
Example #26
0
 public CLoginViewModel(TMember loginMember)
 {
     iv_Member = loginMember;
 }
Example #27
0
        public void saveDepositResult(ViewModelForOPay returnData)
        {
            DateTime         now          = DateTime.Now;
            擺腹BuyFoodContext dbcontext    = new 擺腹BuyFoodContext();
            TMember          changeTarget = dbcontext.TMembers.FirstOrDefault(n => n.CMemberId == int.Parse(returnData.StoreID));

            if (returnData.RtnCode == 1)
            {
                TDeposit result = new TDeposit
                {
                    CMemberId        = int.Parse(returnData.StoreID),
                    CDepositTime     = now,
                    CDepositAmount   = returnData.TradeAmt,
                    CDepositRecordNo = returnData.MerchantTradeNo
                };
                dbcontext.TDeposits.Add(result);
                changeTarget.CDeposit += returnData.TradeAmt;

                int couponCategory = 0;
                switch (returnData.TradeAmt)
                {
                case 1000:
                    couponCategory = 2;
                    break;

                case 2000:
                    couponCategory = 4;
                    break;

                case 5000:
                    couponCategory = 7;
                    break;

                default:
                    break;
                }
                if (couponCategory != 0)
                {
                    string dsCode = "";
                    while (dsCode == "")
                    {
                        bool   check   = false;
                        string newCode = (new ShareFunction()).產生亂數(6);
                        var    data    = dbcontext.TCupons;
                        foreach (var item in data)
                        {
                            if (item.CDiscountCode == newCode)
                            {
                                check = true;
                                break;
                            }
                        }
                        if (!check)
                        {
                            dsCode = newCode;
                        }
                    }
                    TCupon newCoupon = new TCupon
                    {
                        CCuponCategoryId = couponCategory,
                        CMenberId        = int.Parse(returnData.StoreID),
                        CDiscountCode    = dsCode,
                        CValidDate       = now.AddDays(60),
                        CReceivedTime    = now
                    };
                    dbcontext.TCupons.Add(newCoupon);
                }
                dbcontext.SaveChanges();
            }
            string EmailContent = returnData.RtnCode == 1 ?
                                  $"已成功於{now.ToString("yyyy/MM/dd")}加值共{returnData.TradeAmt}擺腹幣" :
                                  $"加值失敗,請重新加值並確認付款內容。";

            (new ShareFunction()).sendGrid(changeTarget.CEmail, changeTarget.CName, "通知-加值結果", EmailContent);
        }
 public void Add(TMember tile)
 {
     scrollBox.Add(tile);
 }
Example #29
0
 /// <summary>
 /// Adds new cluster member.
 /// </summary>
 /// <param name="member">A new member to be added into in-memory collection.</param>
 public void Add(TMember member) => members.AddLast(member);
Example #30
0
        public void InsertMember()
        {
            ConsoleTitleUtil.ShowTestTitle( "InsertMember" );

            TMember member = new TMember();

            member.Name = "����";
            db.insert( member );

            member.Name = "��ԭ";
            db.insert( member );

            member.Name = "���";
            db.insert( member );

            member.Name = "����";
            db.insert( member );

            member.Name = "ׯ��";
            db.insert( member );

            member.Name = "�Ÿ�";
            db.insert( member );

            member.Name = "����";
            db.insert( member );

            member.Name = "������";
            db.insert( member );

            member.Name = "�����";
            db.insert( member );

            member.Name = "�ܲ�";
            db.insert( member );

            member.Name = "˾��Ǩ";
            db.insert( member );

            member.Name = "����ɽ";
            db.insert( member );

            member.Name = "Ԭ����";
            db.insert( member );

            member.Name = "�";
            db.insert( member );

            Console.WriteLine( "��� member �ɹ���" );
        }
Example #31
0
 public CLoginViewModel()
 {
     iv_Member = new TMember();
 }
 public MemberCenterViewModel()
 {
     iv_member          = new TMember();
     iv_issueComboCount = 0;
 }