Exemplo n.º 1
0

        
Exemplo n.º 2
0
        public UsrModel Load(string wecharid)
        {
            var dbContext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>();
            var entity    = dbContext.Usr.SingleOrDefault(s => s.WechatID == wecharid);

            if (entity == null)
            {
                return(null);
            }
            var model = new UsrModel()
            {
                ID           = entity.ID,
                WechatID     = entity.WechatID,
                Code         = entity.Code,
                Name         = entity.Name,
                Desc         = entity.Desc,
                Tel          = entity.Tel,
                Tel1         = entity.Tel1,
                Mobile       = entity.Mobile,
                Mobile1      = entity.Mobile1,
                Addr         = entity.Addr,
                Addr1        = entity.Addr1,
                DepartmentID = entity.DepartmentID,
                VendorID     = entity.VendorID,
                RoleID       = entity.RoleID,
                Disable      = entity.Disable
            };

            return(model);
        }
Exemplo n.º 3
0

        
Exemplo n.º 4
0
        private async Task Ssn_Set(UsrModel usr)
        {
            await SessionStorage.SetItemAsync("usr", usr.Usr);

            await SessionStorage.SetItemAsync("nom", usr.Nom);

            await SessionStorage.SetItemAsync("rol", usr.Rol);
        }
Exemplo n.º 5
0
        public async void MarkUsrAsAuth(UsrModel usr)
        {
            var lxIdentity = Identity_Obt(usr.Usr, usr.Nom, usr.Psw, usr.Rol);
            var lxUser     = new ClaimsPrincipal(lxIdentity);

            NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(lxUser)));

            await Ssn_Set(usr);
        }
Exemplo n.º 6
0
        public void Grd(UsrModel usr)
        {
            string lxQry =
                "UPDATE [Usr] " +
                "   SET Nom = @Nom, Psw = @Psw, Rol = @Rol, St = @St, StmMdf = GetDate() " +
                " WHERE Usr = @Usr";

            try {
                using (IDbConnection cnx = SqlCnx) {
                    cnx.Open();
                    cnx.Query(lxQry, usr);
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
Exemplo n.º 7
0
        public async Task <int> Cre(UsrModel usr)
        {
            string lxQry =
                "INSERT INTO [Usr] " +
                "(Usr, Nom, Psw, Rol, St, StmCre, StmMdf) " +
                "OUTPUT Inserted.Usr " +
                "VALUES " +
                "(@Usr, @Nom, @Psw, @Rol, @St, GetDate(), GetDate()) ";

            try {
                using (IDbConnection cnx = SqlCnx) {
                    cnx.Open();
                    var lxRtrnVal = await cnx.ExecuteAsync(lxQry, usr);

                    return((int)lxRtrnVal);
                }
            } catch (Exception ex) {
                throw ex;
            }
        }
Exemplo n.º 8
0
        public override ResponseBase Handler(GetUsrRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }
            var      service = ServiceProvider.GetService <IUsrService>();
            UsrModel model   = null;

            if (request.ID != 0)
            {
                model = service.Load(request.ID);
            }
            else if (!string.IsNullOrWhiteSpace(request.WechatID))
            {
                model = service.Load(request.WechatID);
            }
            return(new ResponseGeneric <UsrModel>()
            {
                Result = 1, ResultInfo = "", Data = model
            });
        }
Exemplo n.º 9
0
        public void Update(UsrModel model)
        {
            var dbContext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>();
            var entity    = dbContext.Usr.SingleOrDefault(s => s.ID == model.ID);

            if (entity == null)
            {
                throw new Exception("用户信息不存在");
            }

            if (string.IsNullOrEmpty(model.Name))
            {
                throw new Exception("用户名称无效");
            }

            if (string.IsNullOrEmpty(model.Code))
            {
                throw new Exception("用户编码无效");
            }
            if (dbContext.Usr.Count(c => c.Code == model.Code && c.ID != model.ID) > 0)
            {
                throw new Exception("用户编码无效");
            }
            entity.Code         = model.Code;
            entity.WechatID     = model.WechatID;
            entity.Name         = model.Name;
            entity.Tel          = model.Tel;
            entity.Tel1         = model.Tel1;
            entity.Mobile       = model.Mobile;
            entity.Mobile1      = model.Mobile1;
            entity.RoleID       = model.RoleID;
            entity.DepartmentID = model.DepartmentID;
            entity.Desc         = model.Desc;
            entity.VendorID     = model.VendorID;
            entity.Disable      = model.Disable;
            dbContext.Update(entity);
            dbContext.SaveChanges();
        }
Exemplo n.º 10
0
        public void Add(UsrModel model)
        {
            if (string.IsNullOrEmpty(model.Name))
            {
                throw new Exception("用户名称无效");
            }
            var dbContext = ServiceProvider.GetDbcontext <IPurocumentDbcontext>();

            if (string.IsNullOrEmpty(model.Code))
            {
                throw new Exception("用户编码无效");
            }
            if (dbContext.Usr.Count(c => c.Code == model.Code) > 0)
            {
                throw new Exception("用户编码无效");
            }
            var entity = new Usr()
            {
                WechatID     = model.WechatID,
                Code         = model.Code,
                Name         = model.Name,
                Desc         = model.Desc,
                Tel          = model.Tel,
                Tel1         = model.Tel1,
                Mobile       = model.Mobile,
                Mobile1      = model.Mobile1,
                Addr         = model.Addr,
                Addr1        = model.Addr1,
                DepartmentID = model.DepartmentID,
                VendorID     = model.VendorID,
                RoleID       = model.RoleID,
                Disable      = model.Disable
            };

            dbContext.Add(entity);
            dbContext.SaveChanges();
        }