Ejemplo n.º 1
0
        public ActionResult Edit(string id, HuiYuan entity)
        {
            if (entity != null && ModelState.IsValid)
            {   //数据校验

                Account account = GetCurrentAccount(); if (account != null) entity.BiaoShi = account.BiaoShi; else { entity.BiaoShi = "logo"; }

                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",会员信息的Id为" + id, "会员"
                        );//写入日志                           
                    return Json(Suggestion.UpdateSucceed); //提示更新成功 
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return true;
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",会员信息的Id为" + id + "," + returnValue, "会员"
                        );//写入日志                           
                    return Json(Suggestion.UpdateFail + returnValue); //提示更新失败
                }
            }
            return Json(Suggestion.UpdateFail + "请核对输入的数据的格式"); //提示输入的数据的格式不对               

        }
Ejemplo n.º 2
0
        public ActionResult Register(RegisterViewModel model)
        {
            SuggestionRes response = new SuggestionRes();

            #region 各种校验

            if (string.IsNullOrWhiteSpace(model.BiaoShi))
            {//标识是否存在
                response.errorCode = 11;
                return Json(response);
            }
            var vali = Validator.IsPassword(model.Password);
            if (vali != 0)
            {//标识是否存在
                response.errorCode = vali;
                return Json(response);
            }

            if (model.Password != model.ConfirmPassword)
            {
                response.errorCode = 9;
                return Json(response);
            }
            if (string.IsNullOrWhiteSpace(model.UserName))
            {
                response.errorCode = 20;
                return Json(response);
            }
            if (model.UserName.Length > 50)
            {
                response.errorCode = 21;
                return Json(response);
            }
            if (!Validator.IsMobile(model.UserName))
            {
                response.errorCode = 22;
                return Json(response);
            }


            #endregion

            Langben.IBLL.IHuiYuanBLL m_BLL = new HuiYuanBLL();

            if (m_BLL.IsPhone(model.UserName, model.BiaoShi))
            {
                response.errorCode = 23;
                return Json(response);
            }
            ValidationErrors validationErrors = new ValidationErrors();

            HuiYuan entity = new HuiYuan()
            {
                Password = model.Password
                ,
                PhoneNumber = model.UserName
                ,
                CreateTime = DateTime.Now
                ,
                BiaoShi = model.BiaoShi
                ,
                State = "未审核"
                ,
                LogonIP = Common.IP.GetIP()
                

            };
            entity.Id = Result.GetNewId();
            string returnValue = string.Empty;
            if (m_BLL.Create(ref validationErrors, entity))
            {
                response.errorCode = 0;
                return Json(response);
            }
            else
            {
                if (validationErrors != null && validationErrors.Count > 0)
                {
                    validationErrors.All(a =>
                    {
                        returnValue += a.ErrorMessage;
                        return true;
                    });
                }
                //LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",注册的信息," + returnValue, "注册"
                //      );//写入日志   
                response.errorCode = 99;
                return Json(response);         //提示插入失败
            }


        }
Ejemplo n.º 3
0
        public ActionResult Create(HuiYuan entity)
        {
            if (entity != null && ModelState.IsValid)
            {
                Account account = GetCurrentAccount(); if (account != null) entity.BiaoShi = account.BiaoShi; else { entity.BiaoShi = "logo"; }
                entity.CreateTime = DateTime.Now;



                entity.Id = Result.GetNewId();
                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",会员的信息的Id为" + entity.Id, "会员"
                        );//写入日志 
                    return Json(Suggestion.InsertSucceed);
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return true;
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",会员的信息," + returnValue, "会员"
                        );//写入日志                      
                    return Json(Suggestion.InsertFail + returnValue); //提示插入失败
                }
            }

            return Json(Suggestion.InsertFail + ",请核对输入的数据的格式"); //提示输入的数据的格式不对 
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 创建一个会员
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个会员</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, HuiYuan entity)
 {
     try
     {
         repository.Create(entity);
         return true;
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);                
     }
     return false;
 }