Ejemplo n.º 1
0
        public JsonResult GetOne(int id)
        {
            SysUserDTO.SaveModel model = new SysUserDTO.SaveModel();

            var entity = userPrivoder.Single(c => c.Id == id);

            if (entity != null)
            {
                model.Source = entity;
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult GetOne(int id)
        {

            SysUserDTO.SaveModel model = new SysUserDTO.SaveModel();

            var entity = userPrivoder.Single(c => c.Id == id);
            if (entity != null)
            {
                model.Source = entity;

            }
            return Json(model,JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 3
0
        public JsonResult Save(SysUserDTO.SaveModel model)
        {
            if (!ModelState.IsValid)
            {
                return(ModelState.GetFirstErrorMessageResult());
            }

            var iret = 0;

            if (model.Id == 0)
            {
                //验证用户名称是否存在
                if (userPrivoder.Count(c => c.Name == model.Name) > 0)
                {
                    ModelState.AddModelError("0", "用户名已存在");
                    return(ModelState.GetFirstErrorMessageResult());
                }
                model.Source.Statue = (int)UserStatue.Success;
                var ioret = userPrivoder.Add(model.Source);
                iret = Convert.ToInt32(ioret.Id);
            }
            else
            {
                iret = userPrivoder.Update(c => c.Id == model.Id, c => new SysUserInfo()
                {
                    RealName = model.RealName,
                    Tel      = model.Tel,
                    Statue   = model.Statue,
                    RoleId   = model.RoleId
                });
            }


            var js = new AjaxResult()
            {
                Success = true,
                Message = "操作成功!"
            };

            if (iret == 0)
            {
                js.Success = false;
                js.Message = "操作失败";
            }

            return(Json(js));
        }