Exemple #1
0
        //刪除照片
        public IEnumerable <TProductPic> RemoveImg(string img)
        {
            WeNeedFriendsFINContext db  = new WeNeedFriendsFINContext();
            TProductPic             pic = db.TProductPics.FirstOrDefault(n => n.Fid == int.Parse(img));

            db.TProductPics.Remove(pic);
            db.SaveChanges();
            var Pic2 = db.TProductPics.Select(n => n);

            return(Pic2);
        }
Exemple #2
0
        //重設密碼雙重驗證
        public IActionResult redirectpassword(int?first, int?second, int?id)
        {
            WeNeedFriendsFINContext db = new WeNeedFriendsFINContext();

            if (first == second)
            {
                Member member = db.Members.FirstOrDefault(n => n.FUserId.Equals(id));
                member.FPassword = first.ToString();
                db.SaveChanges();
                return(Json("true"));
            }


            return(Json("false"));
        }
        public IActionResult EditProduct1(int?id)
        {
            WeNeedFriendsFINContext db = new WeNeedFriendsFINContext();
            var Products = db.TProducts.ToList().GroupJoin(db.TProductPics, p => p.FProductId, ph => ph.FProductId, (p, pho) => new tProductViewModel
            {
                FProductId          = p.FProductId,
                FProductName        = p.FProductName,
                FProductPrice       = p.FProductPrice,
                FProductDescription = p.FProductDescription,
                FProductQty         = p.FProductQty,
                FProductCategoryId  = p.FProductCategory,
                Pics = pho,
                Size = p.FSize
            }).FirstOrDefault(n => n.FProductId == id);

            return(View(Products));
        }
Exemple #4
0
        public IActionResult ForgetPassWord(string subject, string body, string to)
        {
            WeNeedFriendsFINContext db = new WeNeedFriendsFINContext();

            if (to != null)
            {
                Member email = db.Members.FirstOrDefault(n => n.FEmail.Equals(to));
                if (email == null)
                {
                    return(Json("false"));
                }
                if (email != null)
                {
                    //HttpContext.Session.SetInt32(CDictionary.CURRENT_FORGOTPASSWORD_USERID,email.FUserId);
                    //ViewBag.USERFG = HttpContext.Session.GetInt32(CDictionary.CURRENT_LOGINED_USERID);
                    var message = new MimeMessage();
                    message.From.Add(new MailboxAddress("魔人揪揪團隊", "*****@*****.**"));

                    message.To.Add(new MailboxAddress(to));

                    message.Subject = subject;

                    var builder = new BodyBuilder();


                    //builder.HtmlBody = body;
                    builder.HtmlBody =
                        string.Format(@"<p>您的暫時密碼如下:</p></br>
                                        <h2>12345</h2>");
                    message.Body = builder.ToMessageBody();

                    using (var client = new SmtpClient())
                    {
                        client.ServerCertificateValidationCallback = (s, c, h, e) => true;
                        client.Connect("smtp.gmail.com", 587);
                        client.Authenticate("*****@*****.**", "@Momopalace123@");
                        client.Send(message);
                        client.Disconnect(true);
                    }

                    return(Json(email.FUserId));
                }
            }

            return(Json("false"));
        }
Exemple #5
0
 public JsonResult getDistrict(string city)
 {
     try
     {
         if (city != "請選擇")
         {
             var cityID   = new WeNeedFriendsFINContext().TCities.FirstOrDefault(n => n.FCityName == city);
             var district = new WeNeedFriendsFINContext().TLocations.Where(d => d.FCityId == cityID.FCityId).Select(n => n.FDistrictName);
             return(Json(district));
         }
         return(Json(0));
     }
     catch
     {
         return(Json(0));
     }
 }
        public JsonResult getPost(int user)
        {
            var post = new WeNeedFriendsFINContext().TPosts.Where(u => u.FUserId == user).Select(n => new CCalenderViewModel
            {
                FPostId       = n.FPostId,
                FTitle        = n.FTitle,
                FPostTime     = n.FPostTime,
                FPeople       = n.FPeople,
                FPostAddress  = n.FPostAddress,
                FPostCity     = n.FPostCity,
                FPostDistrict = n.FPostDistrict,
                joinpeople    = n.TJoinPeople.Where(m => m.FUserId == m.FUserId).Count(),
                FDescription  = n.FDescription,
                FSportName    = n.FSportName,
                FUserName     = n.FUser.FUserName
            }).ToList();

            return(Json(post));
        }
Exemple #7
0
 public CPostController(WeNeedFriendsFINContext wnf)
 {
     db = wnf;
 }
Exemple #8
0
        public IActionResult Login(string p, string date, string password, string random)
        {
            WeNeedFriendsFINContext db = new WeNeedFriendsFINContext();
            Member member = db.Members.FirstOrDefault(n => n.FEmail.Equals(p) && n.FPassword.Equals(password));

            if (random == null)
            {
                return(Json("0"));
            }
            if (member != null && random.Equals(HttpContext.Session.GetString(CDictionary.LOGIN_AUTHTICATION_CODE)))
            {
                var q = db.ChangeStatusDates.Where(n => n.Userid.Equals(member.FUserId) && n.Status == true).ToList();
                if (q != null)
                {
                    foreach (var item in q)
                    {
                        long time  = long.Parse(item.Recoverytime);
                        long today = long.Parse(date);
                        if (time - today <= 0)
                        {
                            item.Status    = false;
                            member.Fstatus = 1;
                            db.SaveChanges();
                            HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERSTATUS, (int)member.Fstatus);
                            HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERNAME, member.FUserName);
                            HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERID, member.FUserId);
                            HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERPHOTO, member.FUserPhoto);
                            return(Json(member.Fstatus));
                        }

                        return(Json(member));
                    }
                }

                if (member.Fstatus == 1)
                {
                    HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERSTATUS, (int)member.Fstatus);
                    HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERNAME, member.FUserName);
                    HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERID, member.FUserId);
                    HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERPHOTO, member.FUserPhoto);

                    return(Json(member));
                }


                if (member.Fstatus == 3)
                {
                    HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERSTATUS, (int)member.Fstatus);
                    HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERNAME, member.FUserName);
                    HttpContext.Session.SetInt32(CDictionary.CURRENT_LOGINED_USERID, member.FUserId);
                    HttpContext.Session.SetString(CDictionary.CURRENT_LOGINED_USERPHOTO, member.FUserPhoto);

                    return(Json(member));
                }
            }
            else if (member == null || !random.Equals(HttpContext.Session.GetString(CDictionary.LOGIN_AUTHTICATION_CODE)))
            {
                return(Json("0"));
            }
            return(Json(member));
        }