Ejemplo n.º 1
0
        /// <summary>
        ///     删除白名单
        /// </summary>
        /// <param name="wl">白名单实体</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Delete(WhiteList wl)
        {
            int rcount = WhiteListRepository.Delete(wl);

            if (rcount > 0)
            {
                return(new OperationResult(OperationResultType.Success, "删除白名单成功。", wl));
            }
            else
            {
                return(new OperationResult(OperationResultType.Warning, "删除白名单失败。"));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     添加白名单
        /// </summary>
        /// <param name="prizebetting">奖品信息</param>
        /// <returns>业务操作结果</returns>
        public OperationResult Add(int memberid, Guid poid)
        {
            try
            {
                List <SqlParameter> paramList = new List <SqlParameter>();

                //用户ID
                SqlParameter paramMemberId = new SqlParameter("@MemberId", SqlDbType.Int);
                paramMemberId.Value = memberid;
                paramList.Add(paramMemberId);
                //PrizeOrder Id
                SqlParameter paramPI = new SqlParameter("@PrizeOrderId", SqlDbType.VarChar, 100);
                paramPI.Value = poid.ToString();
                paramList.Add(paramPI);

                SqlParameter paramerrorcode = new SqlParameter("@ErrorCode", SqlDbType.VarChar, 10);
                paramerrorcode.Direction = ParameterDirection.Output;
                paramList.Add(paramerrorcode);

                SqlCommand command = new SqlCommand();
                DataSet    ds      = WhiteListRepository.ExecProcdureReturnDataSet("sp_addToWhiteList", out command, paramList.ToArray());

                string errorCode = command.Parameters["@ErrorCode"].Value.ToString();
                if (string.IsNullOrEmpty(errorCode))
                {
                    return(new OperationResult(OperationResultType.Success, "添加白名单成功。", null));
                }
                else
                {
                    switch (errorCode)
                    {
                    case "Error_01":
                        return(new OperationResult(OperationResultType.Warning, "白名单数目不能超过中奖人数。", null));

                    case "Error_02":
                        return(new OperationResult(OperationResultType.Warning, "该用户已在白名单中,不能重复添加。", null));

                    default:
                        return(new OperationResult(OperationResultType.Warning, "出错了。", null));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }
        public ActionResult SaveWhiteListNumber(WhiteListViewModel vm)
        {
            ControllerReturnStatus status = ControllerReturnStatus.Success;
            string additionalErrInfo      = string.Empty;

            var ad = GetAdInfo();

            string fullName      = ad [0];
            string loginIdentity = ad [1];
            string department    = ad [2];

            try {
                var repo = new WhiteListRepository();
                repo.AddWhiteListPhoneNumber(vm.PhoneNumber, loginIdentity, fullName, department, vm.Notes, vm.DncOverride);
            } catch (Exception ex) {
                status = ControllerReturnStatus.Fail;
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.ToString().Contains("duplicate"))
                    {
                        additionalErrInfo = " was NOT added to white list because it already is in the white list - by user ";
                    }
                }
            }

            // Tell the modal what happened when we tried to save.
            string formattedPhone = Helpers.FormatPhoneNumber(vm.PhoneNumber);

            string message = "Phone number: " + formattedPhone;

            if (additionalErrInfo == string.Empty)
            {
                additionalErrInfo = " was NOT added to white list by user ";
            }
            message += (status == 0 ? " was successfully added to white list by user " + fullName + " DNC-Override set to:" + vm.DncOverride : additionalErrInfo + fullName + " DNC-Override set to:" + vm.DncOverride);

            string title = (status == 0 ? "Success on adding phone number " + formattedPhone : "Error on adding phone number " + formattedPhone);

            var result = new { Status = status, Title = title, Message = message };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            //// *****************
            //// http://stackoverflow.com/a/23273257
            //// http://forums.asp.net/t/1982430.aspx?ASP+NET+Identity+2+0+How+to+add+a+User+to+a+Role+

            //var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());
            //string roleName = "Admin";

            ////Create Role Admin if it does not exist
            //if (!roleManager.RoleExists(roleName))
            //{
            //    var roleresult = roleManager.Create(new IdentityRole(roleName));
            //}

            //roleManager.Create(new IdentityRole(roleName));
            //UserManager.AddToRole(user.Id, "This Is A Test");


            //// *****************



            // *****************
            var status = "ApprovedByDefault";

            var _whiteListRepository = new WhiteListRepository(); // TODO: re-factor this
            var tmp = _whiteListRepository.Get("itcongress2015", model.Email);

            if (tmp == 0) //not found
            {
                status = "WaitingForApproval";
            }

            var  repo = new UserRepository();
            long id2  = repo.getMaxId() + 1;
            // *****************

            var user = new ApplicationUser()
            {
                UserName  = model.Email, Email = model.Email, Hometown = model.Hometown, PhoneNumber = model.PhoneNumber, Owner = model.Owner,
                FirstName = model.FirstName, LastName = model.LastName, Title = model.Title, Company = model.Company, Status = status, Id2 = id2
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);



            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            return(Ok());
        }
Ejemplo n.º 5
0
        public string validate(SessionModel session)
        {
            BlackListRepository bl = new BlackListRepository();
            WhiteListRepository wl = new WhiteListRepository();

            if (!Checkers.IsPhoneNumber(session.sender))
            {
                return("Invalid phone number");
            }

            if (!Checkers.IsPhoneNumber(session.receiver))
            {
                return("Invalid phone number");
            }


            if (Checkers.checkingInputs(session.sender))
            {
                return(Properties.Settings.Default.MESSAGE_INVALID_INPUT.Replace("%PARAM%", "MSISDN"));
            }

            if (Checkers.checkingInputs(session.receiver))
            {
                return(Properties.Settings.Default.MESSAGE_INVALID_INPUT.Replace("%PARAM%", "receiver"));
            }

            if (Checkers.checkingInputs(session.amount))
            {
                return(Properties.Settings.Default.MESSAGE_INVALID_INPUT.Replace("%PARAM%", "amount"));
            }

            if (Checkers.checkingInputs(session.pin))
            {
                return(Properties.Settings.Default.MESSAGE_INVALID_INPUT.Replace("%PARAM%", "pin"));
            }


            // Only validate blaclist
            if (bl.CheckExists(session.sender))
            {
                return(Properties.Settings.Default.BLACK_LIST_MESSAGE);
            }


            if (!wl.CheckExists(session.sender, 1))
            {
                return(Properties.Settings.Default.TC_SA_LIST_MESSAGE);
            }


            if (!wl.CheckExists(session.receiver, 2))
            {
                return(Properties.Settings.Default.DL_TL_LIST_MESSAGE.Replace("%RECEIVER%", session.receiver));
            }


            if (Convert.ToDecimal(session.amount) < Convert.ToDecimal(Properties.Settings.Default.PARAM_MINIMUM_AMOUNT))
            {
                return(Properties.Settings.Default.MESSAGE_MINIMUM_ALLOWED_AMOUNT.Replace("%AMOUNT%", Properties.Settings.Default.PARAM_MINIMUM_AMOUNT));
            }

            return("ok");
        }
Ejemplo n.º 6
0
        /// <summary>
        ///  取待添加至白名单的用户
        /// </summary>
        /// <param name="pageSize">每页输出的记录数</param>
        /// <param name="pageIndex">当前页数</param>
        /// <param name="whereString">条件字符串</param>
        /// <param name="orderbyString">排序字符串</param>
        /// <param name="totalCount">返回总记录</param>
        /// <param name="totalPageCount">返回总页数</param>
        /// <param name="revealstate">奖单ID</param>
        /// <returns></returns>
        public OperationResult GetUsers(int pageSize, int pageIndex, string whereString, string orderbyString, out int totalCount, out int totalPageCount, Guid poid)
        {
            totalCount     = 0;
            totalPageCount = 0;
            try
            {
                List <SqlParameter> paramList = new List <SqlParameter>();

                //每页输出的记录数
                SqlParameter paramPS = new SqlParameter("@PageSize", SqlDbType.Int);
                paramPS.Value = pageSize;
                paramList.Add(paramPS);
                //当前页数
                SqlParameter paramPI = new SqlParameter("@PageIndex", SqlDbType.Int);
                paramPI.Value = pageIndex;
                paramList.Add(paramPI);
                //where条件字符串
                SqlParameter paramWhere = new SqlParameter("@Where", SqlDbType.VarChar, 2000);
                paramWhere.Value = whereString;
                paramList.Add(paramWhere);
                //排序字符串
                SqlParameter paramOrder = new SqlParameter("@Order", SqlDbType.VarChar, 1000);
                paramOrder.Value = orderbyString;
                paramList.Add(paramOrder);
                //奖单ID
                SqlParameter paramPOId = new SqlParameter("@PrizeOrderId", SqlDbType.VarChar, 100);
                paramPOId.Value = poid.ToString();
                paramList.Add(paramPOId);

                SqlParameter paramtc = new SqlParameter("@TotalCount", SqlDbType.Int);
                paramtc.Direction = ParameterDirection.Output;
                paramList.Add(paramtc);
                SqlParameter paramtpc = new SqlParameter("@TotalPageCount", SqlDbType.Int);
                paramtpc.Direction = ParameterDirection.Output;
                paramList.Add(paramtpc);
                SqlParameter paramerrorcode = new SqlParameter("@ErrorCode", SqlDbType.VarChar, 10);
                paramerrorcode.Direction = ParameterDirection.Output;
                paramList.Add(paramerrorcode);

                SqlCommand command = new SqlCommand();
                DataSet    ds      = WhiteListRepository.ExecProcdureReturnDataSet("sp_getUsersForWhiteList", out command, paramList.ToArray());

                string errorCode = command.Parameters["@ErrorCode"].Value.ToString();
                if (string.IsNullOrEmpty(errorCode))
                {
                    totalCount     = Convert.ToInt32(command.Parameters["@TotalCount"].Value);
                    totalPageCount = Convert.ToInt32(command.Parameters["@TotalPageCount"].Value);
                    return(new OperationResult(OperationResultType.Success, "模糊查询用户操作顺利。", ds));
                }
                else
                {
                    switch (errorCode)
                    {
                    case "Error_01":
                        return(new OperationResult(OperationResultType.Warning, "白名单数目不能超过中奖人数。", null));

                    default:
                        return(new OperationResult(OperationResultType.Warning, "出错了。", null));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(new OperationResult(OperationResultType.Error, ex.Message));
            }
        }