Пример #1
0
 public ActionResult Add(LotteryCompany model)
 {
     if (!ModelState.IsValid)
     {
         if (Request.IsAjaxRequest())
         {
             JsonResultModel result = new JsonResultModel
             {
                 IsSuccess = false,
                 Message = ModelState.ToErrorString()
             };
             return Json(result);
         }
         else
         {
             return View(model);
         }
     }
     CompanyManager.Add(model, CurrentUser);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.AddLotteryCompany, LogResources.GetAddLotteryCompany(model.Name, model.CompanyId));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success,
             Model = model
         };
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
Пример #2
0
 public ActionResult NoPermissions()
 {
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel();
         result.IsSuccess = false;
         result.Message = Resource.NoPermission;
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     else
         return View();
 }
        public ActionResult Add(ShadowAuthModel model)
        {
            JsonResultModel result = new JsonResultModel();
            if (!(result.IsSuccess = ModelState.IsValid))
            {
                result.Message = ModelState.ToErrorString();
                return Json(result);
            }

            AuthManager.AddAuth(model.ToAuthAction(), model.AuthRole);
            result.Message = "成功!";
            return Json(result);
        }
Пример #4
0
 public ActionResult BetLimit(int Id, IEnumerable<BetLimit> model)
 {
     if (Id == 0) PageNotFound();
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         User user = UserManager.GetUser(Id);
         if (!EditCompanySelf(user) && (user == null || user.ParentId != MatrixUser.UserId))     //只有父级用户才能修改下级的佣金
             throw new NoPermissionException("Edit BetLimit");
         UserLimitManager.UpdateBetLimit(user, model);
         ActionLogger.Log(CurrentUser, user, LogResources.UpdateUserBetLimit, LogResources.GetUpdateUserBetLimit(user.UserName));
         result.Message = Resource.Success;
     }
     return Json(result);
 }
Пример #5
0
 public ActionResult AmountBoard()
 {
     var freeze = FreezeManager.GetFreezeFund(CurrentUser);
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Model = new
             {
                 BetCredit = CurrentUser.UserInfo.AvailableGivenCredit.ToString(),
                 Outstanding = freeze.Amount.ToString()
             }
         };
         return Json(result, JsonRequestBehavior.AllowGet);
     }
     else
     {
         ViewBag.BetCredit = CurrentUser.UserInfo.AvailableGivenCredit;
         ViewBag.Outstanding = freeze == null ? 0 : freeze.Amount;
         return View();
     }
 }
Пример #6
0
 public ActionResult AddLotteryResult(int? Id, IEnumerable<LotteryRecord> model)
 {
     if (!Id.HasValue) PageNotFound();
     if (!ModelState.IsValid)
     {
         return Json(new JsonResultModel { IsSuccess = false, Message = ModelState.ToErrorString() });
     }
     CompanyManager.AddLotteryResult(Id.Value, model);
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success
         };
         return Json(result);
     }
     else
         return RedirectToAction("AddLotteryResult", new { Id = Id.Value });
 }
Пример #7
0
 public ActionResult UpdateLotteryCompany()
 {
     TodayLotteryCompany.Instance.UpdateTodayLotteryCompany();
     LotterySystem.ClearAllCompany();
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success
         };
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
Пример #8
0
 public ActionResult EditCycle(int? Id, IEnumerable<DayOfWeek> model)
 {
     if (!Id.HasValue) PageNotFound();
     model = model ?? Enumerable.Empty<DayOfWeek>();
     CompanyManager.UpdateCycles(Id.Value, model);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.UpdateLotteryCompanyCycle, LogResources.GetUpdateLotteryCompanyCycle(Id.Value, model));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success
         };
         return Json(result);
     }
     else
         return SuccessAction();
 }
Пример #9
0
 public ActionResult Edit(int? Id, LotteryCompany model)
 {
     if (!Id.HasValue) PageNotFound();
     if (!ModelState.IsValid)
     {
         if (Request.IsAjaxRequest())
         {
             JsonResultModel result = new JsonResultModel
             {
                 IsSuccess = false,
                 Message = ModelState.ToErrorString()
             };
             return Json(result);
         }
         else
             return View(model);
     }
     var company = CompanyManager.GetCompany(Id.Value);
     UpdateModel(company);
     CompanyManager.Update(company, CurrentUser);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.UpdateLotteryCompany, LogResources.GetUpdateLotteryCompany(company.Name, company.CompanyId));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel
         {
             IsSuccess = true,
             Message = Resources.Resource.Success,
             Model = company
         };
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
Пример #10
0
 public ActionResult Add(RegisterModel model)
 {
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
         return Json(result);
     }
     if (!EncryptHelper.Equal(model.YourPassword, CurrentUser.UserInfo.Password))
     {
         result.IsSuccess = false;
         result.Message = Resource.PasswordError;
         return Json(result);
     }
     try
     {
         AddUser(model);
         result.Message = Resource.Success;
         result.Model = model;
     }
     catch (Exception ex)
     {
         result.IsSuccess = false;
         result.Message = ex.Message;
         //TODO:筛选各种异常,并记录异常信息
     }
     return Json(result);
 }
Пример #11
0
 public ActionResult EditShadow(ShadowModel model, int Id = 0)
 {
     if (Id == 0) PageNotFound();
     ModelState.Remove("UserName");
     ModelState.Remove("Password");
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         var user = UserManager.GetUser(Id);
         if (user == null || user.ParentId != CurrentUser.UserId)
             throw new NoPermissionException("Update Shadow");
         if (result.IsSuccess = EncryptHelper.Equal(model.YourPassword, CurrentUser.UserInfo.Password))
         {
             user.UserInfo.Name = model.Name;
             user.UserInfo.State = model.State;
             user.UserInfo.Email = model.Email;
             UserManager.UpdateShadow(user, model.AuthActions);
             ActionLogger.Log(CurrentUser, user, LogResources.EditShadow, LogResources.GetEditShadow(user.UserName));
             result.Message = Resource.Success;
         }
         else
             result.Message = Resource.PasswordError;
     }
     return Json(result);
 }
Пример #12
0
 public ActionResult Edit(int Id, User model, FormCollection form)
 {
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         var user = UserManager.GetUser(Id);
         var shareRate = user.UserInfo.ShareRate;
         if (user.ParentId != MatrixUser.UserId) throw new NoPermissionException("Update User");
         if (result.IsSuccess = EncryptHelper.Equal(model.UserInfo.Password, CurrentUser.UserInfo.Password))
         {
             UpdateModel(user);
             Dictionary<LotterySpecies, int> groups = null;
             if (user.Role == Role.Guest)
             {
                 groups = new Dictionary<LotterySpecies, int>();
                 groups.Add(LotterySpecies.VietnamLottery, int.Parse(form["MemberPack"]));
             }
             bool changeShareRate;
             var update_user = UserManager.UpdateUser(user, groups, out changeShareRate);
             var change_rate_str = changeShareRate ? string.Format(", Change Share Rate : from {0}", shareRate) : string.Empty;
             ActionLogger.Log(CurrentUser, user, LogResources.EditUser, LogResources.GetEditUser(user.UserName) + change_rate_str);
             result.Message = Resource.Success;
             if (user.UserInfo.ShareRate > update_user.UserInfo.ShareRate)
             {
                 result.Message = Resource.ShareRate + " " + Resource.Error;
                 return Json(result);
             }
         }
         else
             result.Message = Resource.PasswordError;
     }
     return Json(result);
 }
Пример #13
0
 public ActionResult AddShadow(ShadowModel model)
 {
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         if (result.IsSuccess = EncryptHelper.Equal(model.YourPassword, CurrentUser.UserInfo.Password))
         {
             var user = model.ToUser();
             user.ParentId = CurrentUser.UserId;
             UserManager.AddShadow(user, model.AuthActions);
             ActionLogger.Log(CurrentUser, user, LogResources.AddShadow, LogResources.GetAddShadow(model.UserName));
             result.Message = Resource.Success;
             result.Model = model;
         }
         else
             result.Message = Resource.PasswordError;
     }
     return Json(result);
 }
Пример #14
0
 private void ProcessWithAjax(string message)
 {
     JsonResultModel result = new JsonResultModel();
     result.IsSuccess = false;
     result.Message = message;
     JavaScriptSerializer s = new JavaScriptSerializer();
     var html = s.Serialize(result);
     TargetController.Response.ContentType = "text/json";
     TargetController.Response.Write(html);
 }
Пример #15
0
 public ActionResult FastBet3D([ModelBinder(typeof(JsonBinder<FastBetItem>))]FastBetItem fastBet)
 {
     var betResult = BetManager.AddBet(CurrentUser, LotterySpecies.VietnamLottery, fastBet, GameType.ThreeDigital);
     JsonResultModel result = new JsonResultModel();
     result.IsSuccess = true;
     result.Model = BuildBetResult(betResult);
     return Json(result);
 }
Пример #16
0
 public ActionResult Delete(int? Id)
 {
     if (!Id.HasValue) PageNotFound();
     CompanyManager.Remove(Id.Value, CurrentUser);
     ActionLogger.Log(CurrentUser, CurrentUser, LogResources.RemoveLotteryCompany, LogResources.GetRemoveLotteryCompany(Id.Value));
     if (Request.IsAjaxRequest())
     {
         JsonResultModel result = new JsonResultModel();
         result.IsSuccess = true;
         result.Model = Id.Value;
         return Json(result);
     }
     else
         return RedirectToAction("Index");
 }
Пример #17
0
 public ActionResult ABRollParlay([ModelBinder(typeof(JsonBinder<BetItem[]>))]BetItem[] betList)
 {
     var betResult = BetManager.AddUnionPL2Bet(CurrentUser, LotterySpecies.VietnamLottery, betList);
     JsonResultModel result = new JsonResultModel();
     result.IsSuccess = true;
     result.Model = BuildBetResult(betResult);
     return Json(result);
 }
        public ActionResult GetActions(string controllerName)
        {
            controllerName = string.Concat(this.GetType().Namespace, ".", controllerName);
            JsonResultModel result = new JsonResultModel();
            var controllerType = Type.GetType(controllerName);

            if (result.IsSuccess = (controllerType != null))
            {
                var methods = controllerType.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
                    .Where(it => it.ReturnType == typeof(ActionResult) || it.ReturnType.IsSubclassOf(typeof(ActionResult)));
                List<KeyValuePair<string, string>> signs = new List<KeyValuePair<string, string>>();
                foreach (var method in methods)
                {
                    signs.Add(new KeyValuePair<string, string>(method.Name, ParseActionSign(method)));
                }
                result.Model = new { controller = controllerName, actions = signs };
            }
            else
                result.Message = "找不到Controller";
            return Json(result, JsonRequestBehavior.AllowGet);
        }