Пример #1
0
        public User UpdateRoleUser(int?userId, int?roleId)
        {
            using (var db = new ModelContainer())
            {
                var result = db.sp_InsUpdUserRole(userId, roleId).FirstOrDefault();

                if (result != null && result.IsError == true)
                {
                    throw new Exception(result.Message);
                }
                return(new User()
                {
                    UserId = userId
                });
            }
        }
Пример #2
0
        public List <Resource> GetResourcesByUserId(int UserId)
        {
            using (var db = new ModelContainer())
            {
                var collection = db.sp_SelResourceByUserId(UserId);

                var resp = (from x in collection
                            select new Resource()
                {
                    DisplayName = x.DisplayName,
                    Icon = x.Icon,
                    Position = x.Position,
                    ResourceId = x.ResourceId,
                    Url = x.Url,
                    ParentResourceId = x.ParentResourceId,
                    AddMenu = x.Menu
                }).ToList();

                return(resp);
            }
        }
Пример #3
0
        public User insUpdUser(User parameters)
        {
            using (var db = new ModelContainer())
            {
                ObjectParameter UserId = new ObjectParameter("userId", typeof(int?));
                UserId.Value = parameters.UserId;

                //parameters.Password = Crypto.ToBase64(parameters.Password).ToString();
                var result = db.sp_insUpdUser(UserId,
                                              parameters.UserName,
                                              parameters.Password
                                              ).FirstOrDefault();

                if (result != null && result.IsError == true)
                {
                    throw new Exception(result.Message);
                }

                parameters.UserId = Convert.ToInt32(UserId.Value.ToString());
                return(parameters);
            }
        }