コード例 #1
0
 public ActionResult Login(string username, string password, string returnurl) {
     if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { 
             ViewBag.Status = "<span style=\"color:red\">用户名或密码不能为空!</span>";
     }
     BaWuClub.Web.Dal.User user = new User() { NickName=HtmlCommon.ClearHtml(username),Password= System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5")};
     using (club = new ClubEntities()) {
         var _user = club.Users.Where(u =>u.NickName ==user.NickName  && u.Password ==user.Password).FirstOrDefault();
         if (_user!=null){
             if (_user.LastLoginDate < DateTime.Now) {
                 _user.Points += 2;
             }
             _user.LastLoginDate = DateTime.Now;
             _user.LastLoginIP = Request.UserHostAddress;
             club.SaveChanges();
             //System.Web.Security.FormsAuthentication.SetAuthCookie(user.NickName, true);
             //HttpCookie cookie = new HttpCookie("bwusers");
             //cookie.Values["id"] = _user.Id.ToString();
             //cookie.Values["user"] = HttpUtility.UrlEncode(_user.NickName.ToString());
             //cookie.Values["avatar"] = _user.Cover;
             Response.Cookies.Add(SetCookies(_user));
             return RedirectUrl(returnurl);
         }
         else { 
             ViewBag.Status = "<span style=\"color:red\">用户名或密码不正确!</span>";}
     }
     return View();
 }
コード例 #2
0
 public JsonResult MultiDel(string[] chk)
 {
     if (chk.Length == 0)
     {
         hitStr = "未选中行,请选中行后再进行操作!";
     }
     else
     {
         using (club = new ClubEntities())
         {
             foreach (string ck in chk)
             {
                 tId = Convert.ToInt32(ck);
                 var question = club.Questions.Where(b => b.Id == tId).FirstOrDefault();
                 club.Questions.Remove(question);
             }
             if (club.SaveChanges() >= 0)
             {
                 hitStr = "信息删除成功!";
                 status = Status.success;
             }
             else
             {
                 hitStr = "系统异常删除失败,请稍后重试!";
             }
         }
     }
     return Json(new { state = status.ToString(), context = hitStr.ToString(), url = "/bwum/activity/" });
 }
コード例 #3
0
 public ActionResult Save(string title,string keywords,string description,string phone,string fax,string email,string qq,string copyright,string address) {
     Models.SettingModel s = new Models.SettingModel() { 
         Title=title,
         Keywords=keywords,
         Description=description,
         Phone=phone,
         Fax=fax,
         Email=email,
         QQ=qq,
         CopyRight=copyright,
         Address=address
     };
     Status status=Status.error;
     string hitStr=String.Empty;
     Type t=s.GetType();
     using (club = new ClubEntities())
     {
         var Properties = t.GetProperties();
         foreach (var p in Properties) {
             var settting=club.Settings.Where(st => st.SettingName == p.Name).FirstOrDefault();
             if (settting != null)
                 settting.SettingValue = p.GetValue(s, null).ToString();
         }
         if (club.SaveChanges() >= 0) {
             status = Status.success;
             hitStr = "网站信息保存成功!";
         }
         else{
             hitStr = "网站信息保存失败,请稍后重试!";
         }
         ViewBag.StatusStr = HtmlCommon.GetHitStr(hitStr, status);
     }
     return View("~/areas/bwum/views/setting/index.cshtml",GetSettingDic());
 }
コード例 #4
0
 public JsonResult Del(int id) {
     hitStr="删除失败,请稍后重试!";
     using (club = new ClubEntities()) {
         var topic = club.TopicIndexes.Where(t => t.Id == id).FirstOrDefault();
         if (topic.Type == (int)TopicType.Topic) {
             var _topic=club.Topics.Where(t => t.Id == id).FirstOrDefault();
             club.Topics.Remove(_topic);
         }
         else { 
              if (topic.Type == (int)TopicType.Activity) {
                     var _topic=club.TopicActivities.Where(t => t.Id == id).FirstOrDefault();
                     club.TopicActivities.Remove(_topic);
                  }
              else {
                      var _topic = club.TopicTasks.Where(t => t.Id == id).FirstOrDefault();
                      club.TopicTasks.Remove(_topic);
                  }
         }
         club.TopicIndexes.Remove(topic);
         if (club.SaveChanges() >= 0) {
             status = Status.success;hitStr="删除成功!";
         }
     }
     return Json(new { status = status.ToString(), context = HtmlCommon.GetHitStr(status, hitStr) });
 }
コード例 #5
0
 public ActionResult Show(int? id) {
     BaWuClub.Web.Dal.User user = new User() { Id=Convert.ToInt32(id)};
     using (club = new ClubEntities()) {
         user = club.Users.Single<BaWuClub.Web.Dal.User>(u => u.Id == user.Id);
     }
     return View(user);
 }
コード例 #6
0
 public ActionResult Create() {
     activity = new Activity();
     using (club = new ClubEntities()) {
         GetProvince(club);
     }
     return View("~/areas/bwum/views/activity/edit.cshtml",activity);    
 }
コード例 #7
0
 public ActionResult AccountCreate(){
     adminAccount = new AdminAccount();
     using(club=new ClubEntities()){
         ViewBag.adminTypes = GetAdminTypeList(club);
     }
     return View("~/areas/bwum/views/role/accountcreate.cshtml", adminAccount);
 }
コード例 #8
0
 public ActionResult Show(int id) {
     video = new Video();
     using (club = new ClubEntities()) {
         video = club.Videos.Where(v => v.Id == id).FirstOrDefault();
     }
     return View("~/areas/bwum/views/online/show.cshtml",video);
 }
コード例 #9
0
 public ActionResult Main() {
     StringBuilder categories = new StringBuilder();
     StringBuilder series = new StringBuilder();
     using (club = new ClubEntities()) {
         OnStatistics(club);
         var _views = (from v in club.Views orderby v.Id descending select v).Take<View>(7);
         var _v = _views.FirstOrDefault<View>();
         if (_v != null){
             ViewBag.TodayView = _v.Today;
             ViewBag.CountView = _v.Count;                    
         }
         else {
             ViewBag.TodayView =0;
             ViewBag.CountView = 0;
         }
         foreach (View view in _views.OrderBy(v=>v.Id)){
             categories.Append(String.Format(@"{0}", view.Date.ToString("dd")) + ",");
             series.Append(view.Today + ",");
         }
         if (categories.Length > 0)
             categories.Remove(categories.Length-1,1);
         if (series.Length > 0)
             series.Remove(series.Length - 1, 1);
     }
     ViewBag.Categories = categories.ToString();
     ViewBag.Series = series;
     return View("~/Areas/bwum/Views/Um/Main.cshtml");
 }
コード例 #10
0
 public ActionResult Create(string title,int city,string address,string pic,string start,string end,string contact,string phone,string sponsor,string context,string cost,string limited) {
     activity = new Activity() { 
             Title=HtmlCommon.ClearHtml(title),
             CityId=city,
             Address=address,
             StartDate=DateTime.Parse(start), 
             EndDate=DateTime.Parse(end),
             Contact=contact,
             Phone=phone,
             Sponsor=sponsor,
             Context=context,
             Cover=pic,
             Cost=cost,
             Limited=limited,
             VarDate=DateTime.Now
     };
     using (club = new ClubEntities()) {
         club.Activities.Add(activity);
         if (club.SaveChanges() >= 0) {
             status = Status.success;
             hitStr = "活动添加成功!";
         }
         else {
             hitStr = "添加失败,请稍后重试!";
         }
     }
     ViewBag.StatusStr = HtmlCommon.GetHitStr(status,hitStr);
     return View("~/areas/bwum/views/activity/edit.cshtml",activity);
 }
コード例 #11
0
 public static string SendMessge(int form,int to,string title,string message,string ip) {
     Status status = Status.error;
     string hitStr = "操作失败,请重试!";
     using (ClubEntities club = new ClubEntities()) {
         var toUser = club.Users.Where(u => u.Id == to).FirstOrDefault();
         if (toUser != null) {
             Message msg = new Message() { 
                 FromId=form,
                 ToId=to,
                 Title=title,
                 Message1=message,
                 Ip=ip,
                 Vardate=DateTime.Now
             };
             club.Messages.Add(msg);
             if (club.SaveChanges() >0) {
                 status = Status.success;
                 hitStr = "发送成功!";
             }
         }
         else {
             hitStr = "对方账号不存在!";
         }
     }
     return JsonConvert.SerializeObject(new {status=status,context=hitStr });
 }
コード例 #12
0
 public ActionResult Show(int? id,string sort) {
     ViewQuestion vq=new ViewQuestion();
     int qid = id ?? 0;
     ViewBag.CurrentUser = GetUser();
     using (club = new ClubEntities()) {
         vq = club.ViewQuestions.Where(q => q.Id == qid).FirstOrDefault();
         var question = club.Questions.Where(q => q.Id == qid).FirstOrDefault();
         if (question != null) {
             question.Views += 1;
         }
         club.SaveChanges();
         ViewBag.AnswerCount = club.Answers.Where(a => a.QId == qid).Count();
         ViewBag.AnswerVote = club.AnswerVotes.Where(a => a.QId == qid).ToList<AnswerVote>();
         switch(sort){
             case "time":
                 ViewBag.ViewAnswers = GetAnswerList(club, q => q.QId == qid,q=>q.Id,0);
                 break;
             case "vote":
                 ViewBag.ViewAnswers = GetAnswerList(club, q => q.QId == qid, q => q.Agree, 0);
                 break;
             default:
                 ViewBag.ViewAnswers = GetAnswerList(club, q => q.QId == qid,q=>q.Id,0);
                 break;
         }
         if (vq == null)
             return Redirect("/error/notfound");
         ViewBag.Title = vq.Title;
         ViewBag.OtherQuestions = club.Questions.Where(q => q.UserId == vq.UserId&&q.Id!=vq.Id).Take(6).ToList<Question>();
     }
     return View(vq);
 }
コード例 #13
0
 public JsonResult reviews(int id, string commentStr) {
     BaWuClub.Web.Dal.User user = GetUser();
     string url="/account/login";
     string context = string.Empty;
     if (user != null) {
         VideoReview reviews = new VideoReview();
         reviews.UserId=user.Id;
         reviews.VideoId=id;
         reviews.Review=HtmlCommon.ClearJavascript(commentStr);
         reviews.VarDate=DateTime.Now;
         reviews.IP = Request.UserHostAddress;
         using (club = new ClubEntities()) {
             club.VideoReviews.Add(reviews);
             if (club.SaveChanges() >= 0){
                 status = Status.success;
                 StringBuilder str = new StringBuilder();
                 str.Append("<div class=\"comment-item\">");
                 str.Append("<div class=\"comment-item-info\">");
                 str.Append("<a href=\"/member/u-" + user.Id + "/show/\" class=\"comment-item-info-name\">" + user.NickName + "</a>");
                 str.Append("<a href=\"/member/u-" + user.Id + "/show/\" class=\"comment-item-info-avatar\"><img src=\"" + (string.IsNullOrEmpty(user.Cover) ? "/content/images/no-img.jpg" : "~/uploads/avatar/small/" + user.Cover) + "\"/>");
                 str.Append("</a>");
                 str.Append("</div>");
                 str.Append("<div class=\"comment-item-content\">" + HtmlCommon.ClearJavascript(reviews.Review) + "</div>");
                 str.Append("<div class=\"comment-item-meta\"><span>评论与" + HtmlCommon.GetAnswerTimeSpan((DateTime)reviews.VarDate) + "</span></div>");
                 str.Append("</div>");
                 context = str.ToString();
             }
             else{
                 status = Status.warning; context = "系统异常,操作失败,请稍后重试!";
             }
         }                
     }
     return Json(new { status = status.ToString(), context = context, url = url });
 }
コード例 #14
0
 public ActionResult Show(int? id) {
     vId = id ?? 0;
     using (club = new ClubEntities()) {
         article = club.Articles.Where(v => v.Id == vId).FirstOrDefault();
     }
     return View("~/areas/bwum/views/contribute/show.cshtml", article);
 }
コード例 #15
0
 public ActionResult Show(int id) {
     ViewDocument viewDoc = new ViewDocument();
     using (club = new ClubEntities()) {
         viewDoc = club.ViewDocuments.Where(d => d.Id == id).FirstOrDefault();
     }
     return View("~/areas/bwum/views/down/show.cshtml", viewDoc);
 }
コード例 #16
0
 private void SettingCache()
 {
     if (HttpRuntime.Cache["setting"] == null)
     {
         List<Setting> list = new List<Setting>();
         using (ClubEntities club = new ClubEntities())
         {
             list = club.Settings.ToList<Setting>();
         }
         Dictionary<string, object> dic = new Dictionary<string, object>();
          string value=string.Empty;
         foreach (var s in list)
         {
             value=s.SettingValue==null?"":s.SettingValue;
             dic.Add(s.SettingName,value );
         }
         if (dic != null)
             HttpRuntime.Cache.Insert("setting", dic);
         ViewBag.SettingDictionary = HttpRuntime.Cache["setting"];
     }
     else {
         var dic = HttpRuntime.Cache["setting"] as Dictionary<string, object>;
         ViewBag.SettingDictionary = HttpRuntime.Cache["setting"];
     }
 }
コード例 #17
0
 public JsonResult AccountCreate(string username, string password, string confirmpassword, string phone, string email, string realname, string address, string cover) {
     if (string.IsNullOrEmpty(username)) {
         hitStr = "用户名不能为空!";
     }
     else if (string.IsNullOrEmpty(password)) {
         hitStr = "请输入姓名!";
     }
     else if (string.IsNullOrEmpty(confirmpassword)) {
         hitStr = "请输入确认密码!";
     }
     else if (password != confirmpassword) { 
         hitStr = "两次密码输入不一致!";
     }else{
         AdminAccount account = new AdminAccount() { 
             UserName=username,
             PassWord=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5"),
             Phone=phone,
             RealName=realname,
             Address=address,
             Cover=cover,
             Email=email
         };
         using (club = new ClubEntities()) {
             club.AdminAccounts.Add(account);
             if (club.SaveChanges() > 0) {
                 status = Status.success;
                 hitStr = "账号创建成功!";
             }
         }
     }
     return Json(new { status = status.ToString() ,context=hitStr});
 }
コード例 #18
0
        //
        // GET: /bwum/Help/

        public ActionResult Index()
        {
            SystemArticle article = new SystemArticle();
            using (ClubEntities club = new ClubEntities()) {
                article = club.SystemArticles.Where(a => a.Variables == "sys-info-help-um").FirstOrDefault();
            }
            return View("~/areas/bwum/views/help/index.cshtml", article);
        }
コード例 #19
0
 public ActionResult Show(int? id) {
     GetBannerType();
     tId = id ?? 0;
     using (club = new ClubEntities()) {
         banner = club.Banners.Where(b => b.Id == tId).FirstOrDefault();
     }
     return View("~/areas/bwum/views/banner/edit.cshtml",banner);
 }
コード例 #20
0
 public ActionResult Show(int? id) {
     Feedback feedback = new Feedback();
     tId = id ?? 0;
     using (club = new ClubEntities()) {
         feedback = club.Feedbacks.Where(f => f.Id == tId).FirstOrDefault();
     }
     return View("~/areas/bwum/views/feedback/show.cshtml", feedback);
 }
コード例 #21
0
 private static bool IsTagNameRepeate(string tagName) {
     using (club = new ClubEntities()) {
         var _tag = from t in club.Tags.Where(c => c.TagName == tagName) select t;
         if (_tag.Count() > 0)
             return true;
     }
     return false;
 }
コード例 #22
0
 public ActionResult UploadDocs()
 {
     using (club = new ClubEntities()) {
         var shared = club.SystemArticles.Where(s => s.Variables == "sys-info-shared" && s.Status == 1).FirstOrDefault();
         ViewBag.SharedDesc = shared != null ? shared.Text : "";
         ViewBag.DownsTop = GetViewDocumentsOrderByDown(club);
     }
     return View("~/views/download/uploaddocs.cshtml");
 }
コード例 #23
0
 public ActionResult Index(int? id){
     aId=id??1;
     List<Area> list = new List<Area>();
     using (club = new ClubEntities()) {
         list = club.Areas.OrderByDescending(a => a.Id).Skip((aId - 1) * ClubConst.AdminPageSize).Take(ClubConst.AdminPageSize).ToList<Area>();
     }
     ViewBag.PageHtmlStr = HtmlCommon.GetPageStr(ClubConst.AdminPageSize,aId,list.Count());
     return View("~/areas/bwum/views/area/index.cshtml",list);
 }
コード例 #24
0
 public ActionResult Join(int? id) {
     aId=id??0;
     using (club = new ClubEntities()) {
         viewActivity = club.ViewActivities.Where(a => a.Id == aId).FirstOrDefault();
     }
     if (viewActivity == null)
         return Redirect("/error/notfound");
     return View(viewActivity);
 }
コード例 #25
0
 public ActionResult Edit(int? id) {
     Tag tag = new Tag();
     if (string.IsNullOrEmpty(id.ToString()))
         return View(tag);
     using (club = new ClubEntities()) {
         tag = club.Tags.Single(t => t.Id ==id);   
     }
     return View(tag);
 }
コード例 #26
0
 public ActionResult Index(int? page){
     int current = page ?? 1;
     List<ViewDocument> list = new List<ViewDocument>();
     using (club = new ClubEntities()) {
         list = club.ViewDocuments.OrderByDescending(v => v.Id).Skip(ClubConst.AdminPageSize * (current - 1)).Take(ClubConst.AdminPageSize).ToList<ViewDocument>();
         ViewBag.count = club.ViewDocuments.Count();
     }
     ViewBag.PageHtmlStr = HtmlCommon.GetPageStr(ClubConst.AdminPageSize, current, ViewBag.count);
     return View("~/areas/bwum/views/down/index.cshtml", list);
 }
コード例 #27
0
 private void OnStatistics(ClubEntities c) {
     Statistics += Accounts;
     Statistics += Articles;
     Statistics += Asks;
     Statistics += Answers;
     Statistics += Topics;
     if (Statistics != null) {
         Statistics(c);
     }
 }
コード例 #28
0
 public ActionResult Index(int? page){
     int current = page ?? 1;
     List<ViewQuestion> viewQuestions=new List<ViewQuestion>();
     using (club = new ClubEntities()) {
         viewQuestions = club.ViewQuestions.OrderByDescending(v => v.Id).Skip(ClubConst.AdminPageSize * (current - 1)).Take(ClubConst.AdminPageSize).ToList<ViewQuestion>();
         ViewBag.Count=club.ViewQuestions.Count();
     }
     ViewBag.PageHtmlStr = HtmlCommon.GetPageStr(ClubConst.AdminPageSize, current, ViewBag.Count);
     return View(viewQuestions);
 }
コード例 #29
0
 public ActionResult Index(int? id) {
     tId = id ?? 1;
     List<AdminAccount> accounts = new List<AdminAccount>();
     using (club = new ClubEntities()) {
         accounts = club.AdminAccounts.OrderBy(t=>t.Id).Skip((tId - 1) * ClubConst.AdminPageSize).Take(ClubConst.AdminPageSize).ToList<AdminAccount>();
          ViewBag.Count=club.ViewQuestions.Count();
     }
     ViewBag.PageHtmlStr = HtmlCommon.GetPageStr(ClubConst.AdminPageSize, tId, ViewBag.Count);
     return View("~/areas/bwum/views/role/account.cshtml",accounts);
 }
コード例 #30
0
 public ActionResult Edit(int? id) {
     tId = id ?? 1;
     using (club = new ClubEntities())
     {
         topicCategory = club.TopicCategories.Where(t => t.Id == tId).FirstOrDefault();
     }
     if (topicCategory == null)
         return RedirectToAction("notfound","error");
     return View("~/areas/bwum/views/discuss/create.cshtml", topicCategory);
 }