Пример #1
0
        public async Task <ActionResult> AddUserToResource(string data, string fieldPrefix, string newUser)
        {
            // validate
            if (string.IsNullOrWhiteSpace(newUser))
            {
                throw new Error(this.__ResStr("noParm", "No user name specified"));
            }
            int userId = await Resource.ResourceAccess.GetUserIdAsync(newUser);

            if (userId == 0)
            {
                throw new Error(this.__ResStr("noUser", "User {0} doesn't exist.", newUser));
            }
            string userName = await Resource.ResourceAccess.GetUserNameAsync(userId);

            // check duplicate
            List <ResourceUsersEditComponent.Entry> list = Utility.JsonDeserialize <List <ResourceUsersEditComponent.Entry> >(data);

            if ((from l in list where l.UserId == userId select l).FirstOrDefault() != null)
            {
                throw new Error(this.__ResStr("dupUser", "User {0} has already been added", newUser));
            }
            // render
            ResourceUsersEditComponent.Entry entry = new ResourceUsersEditComponent.Entry(userId, userName);
            return(await GridRecordViewAsync(await ResourceUsersEditComponent.GridRecordAsync(fieldPrefix, entry)));
        }
Пример #2
0
 public async Task <ActionResult> ResourceUsersBrowse_GridData(GridPartialViewData gridPVData)
 {
     return(await GridPartialViewAsync(ResourceUsersEditComponent.GetGridAllUsersModel(), gridPVData));
 }
Пример #3
0
 public async Task <ActionResult> ResourceUsersEdit_SortFilter(GridPartialViewData gridPVData)
 {
     return(await GridPartialViewAsync <ResourceUsersEditComponent.Entry>(ResourceUsersEditComponent.GetGridModel(false), gridPVData));
 }