Esempio n. 1
0
        public ActionResult AddFeedbackproduct(Feedbackproduct feedbackproduct)
        {
            if (TryUpdateModel(feedbackproduct, new string[] { "Feedbackproductname" }) && ModelState.IsValid)
            {
                feedbackproduct.Feedbackproductid = Guid.NewGuid();
                feedbackproduct.Uuid       = Guid.NewGuid();
                feedbackproduct.Createdate = DateTime.Now;
                feedbackproduct.Updatedate = DateTime.Now;
                feedbackproductService.Create(feedbackproduct);
                foreach (Feedbackdetail feedbackdetail in feedbackproduct.Feedbackdetail)
                {
                    feedbackdetail.Setid             = Guid.NewGuid();
                    feedbackdetail.Feedbackproductid = feedbackproduct.Feedbackproductid;
                    feedbackdetailService.Create(feedbackdetail);
                }
                feedbackproductService.SaveChanges();

                IEnumerable <Members> member = membersService.Get();
                foreach (Members thismember in member)
                {
                    Memberauthorization memberauth = new Memberauthorization();
                    memberauth.Id                = Guid.NewGuid();
                    memberauth.Memberid          = thismember.Memberid;
                    memberauth.Feedbackproductid = feedbackproduct.Feedbackproductid;
                    memberauth.Checked           = true;
                    memberauthorizationService.Create(memberauth);
                }
                memberauthorizationService.SaveChanges();
            }
            return(RedirectToAction("Feedbackproduct"));
        }
Esempio n. 2
0
        public ActionResult AddMembers(Members members)
        {
            /*** 隨機指派手機版Useragent ***/
            int       useragent_phone = useragentService.Get().Where(a => a.Isweb == 1).Count();
            Random    rnd             = new Random();
            int       rnd_useragent   = rnd.Next(1, useragent_phone);
            Useragent useragent       = useragentService.Get().Where(a => a.Id == rnd_useragent).FirstOrDefault();

            /*** End Useragent ***/

            if (TryUpdateModel(members, new string[] { "Sex", "Account", "Password", "Facebookstauts", "Facebookid", "Feedbackmoney", "Name", "Isenable" }) && ModelState.IsValid)
            {
                members.Memberid        = Guid.NewGuid();
                members.Account         = Regex.Replace(members.Account, @"[^a-z||A-Z||@||.||0-9]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值
                members.Createdate      = DateTime.Now;
                members.Updatedate      = DateTime.Now;
                members.Lastdate        = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds) - 28800; // 總秒數
                members.Isenable        = 1;
                members.Is_import       = 1;
                members.Logindate       = 99999999999;
                members.Isreal          = members.Isreal;
                members.Levelid         = members.Levelid;
                members.Useragent_phone = useragent.User_agent;
                members.Facebookid      = members.Facebookid.Replace("https://www.facebook.com/profile.php?id=", "");
                /**** 將會員寫進會員登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ****/
                Memberloginrecord memberloginrecord = new Memberloginrecord();
                memberloginrecord.Memberid   = members.Memberid;
                memberloginrecord.Createdate = members.Createdate;
                memberloginrecord.Status     = 0;
                members.Memberloginrecord.Add(memberloginrecord);
                /**** End Memberloginrecord ****/
                membersService.Create(members);
                foreach (Memberauthorization memberauthorization in members.Memberauthorization)
                {
                    memberauthorization.Id = Guid.NewGuid();
                    memberauthorizationService.Create(memberauthorization);
                }
                membersService.SaveChanges();
            }

            return(RedirectToAction("Members"));
        }
Esempio n. 3
0
        public JsonResult AjaxMember(Guid uuid)
        {
            Members             Member = membersSerice.GetByID(Session["Memberid"]);
            Memberauthorization memberauthorization = memberauthorizationService.Get().Where(a => a.Memberid == Member.Memberid).Where(x => x.Feedbackproductid == uuid).FirstOrDefault();

            if (memberauthorization != null)
            {
                memberauthorization.Checked = !memberauthorization.Checked;
                memberauthorizationService.SaveChanges();
            }
            else
            {
                memberauthorization                   = new Memberauthorization();
                memberauthorization.Id                = Guid.NewGuid();
                memberauthorization.Memberid          = Member.Memberid;
                memberauthorization.Feedbackproductid = uuid;
                memberauthorization.Checked           = true;
                memberauthorizationService.Create(memberauthorization);
                memberauthorizationService.SaveChanges();
            }
            return(this.Json("success"));
        }