Beispiel #1
0
        public IQueryable <ValueViewModel> Search()
        {
            var formIds = formUserAuthorizationRepository.Search().Where(e => e.UserId == user.Id && e.IsReadData == true).Select(x => x.FormId).ToList();

            return(repository.Search().Where(e => e.UserId == user.Id || formIds.Contains(e.Id) || e.Form.IsPublic == true).Select(x => new ValueViewModel()
            {
                Id = x.Id,
                FormId = x.FormId,
                CreatedDateTime = x.CreatedDateTime,
                ModifiedDateTime = x.ModifiedDateTime,
                Form = new FormViewModel()
                {
                    Id = x.Form.Id,
                    Name = x.Form.Name
                },
                ValueDetails = x.ValueDetails.Select(y => new ValueDetailViewModel()
                {
                    Id = y.Id,
                    Value = y.Value,
                    CreatedDateTime = y.CreatedDateTime,
                    FormDetailsId = y.FormDetailsId,
                    FormDetail = new FormDetailViewModel()
                    {
                        Id = y.FormDetail.Id,
                        Name = y.FormDetail.Name,
                        FormDetailsType = new FormDetailTypeViewModel()
                        {
                            Id = y.FormDetail.FormDetailsType.Id,
                            Name = y.FormDetail.FormDetailsType.Name
                        }
                    }
                })
            }));
        }
Beispiel #2
0
        public bool IsAuthorized(Guid formId, string email, AuthorizationType authorizationType, EndpointType endpointType)
        {
            //Check the base case.  The creator of the form can do everything.
            var form = formRepository.Get(formId).Result;
            var user = userRepository.Search().Where(e => e.Email == email).ToList();

            if (form.UserId == user[0].Id)
            {
                return(true);
            }
            //Otherwise check the who is authorized to do what on this form.
            var credentials = formUserAuthorizationRepository.Search().Where(e => e.FormId == formId && e.AspNetUser.Email == email).ToList();

            if (credentials.Count() > 0)
            {
                if (endpointType == EndpointType.Form)
                {
                    if (authorizationType == AuthorizationType.IsCreate)
                    {
                        return(credentials[0].IsCreateForm);
                    }
                    else if (authorizationType == AuthorizationType.IsRead)
                    {
                        return(credentials[0].IsReadForm);
                    }
                    else if (authorizationType == AuthorizationType.IsUpdate)
                    {
                        return(credentials[0].IsUpdateForm);
                    }
                    else
                    {
                        return(credentials[0].IsDeleteForm);
                    }
                }
                else
                {
                    if (authorizationType == AuthorizationType.IsCreate)
                    {
                        return(credentials[0].IsCreateData);
                    }
                    else if (authorizationType == AuthorizationType.IsRead)
                    {
                        return(credentials[0].IsReadData);
                    }
                    else if (authorizationType == AuthorizationType.IsUpdate)
                    {
                        return(credentials[0].IsUpdateData);
                    }
                    else
                    {
                        return(credentials[0].IsDeleteData);
                    }
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        public IQueryable <FormViewModel> Search()
        {
            var formIds = formUserAuthorizationRepository.Search().Where(e => e.UserId == user.Id && e.IsReadForm == true).Select(x => x.FormId).ToList();

            return(repository.Search().Where(e => e.UserId == user.Id || formIds.Contains(e.Id)).Select(x => new FormViewModel()
            {
                Description = x.Description,
                Id = x.Id,
                CreatedDateTime = x.CreatedDateTime,
                ModifiedDateTime = x.ModifiedDateTime,
                Name = x.Name,
                UserId = x.UserId,
                PublishUrl = x.PublishUrl,
            }));
        }
        public IQueryable <FormDetailViewModel> Search()
        {
            var formIds = formUserAuthorizationRepository.Search().Where(e => e.UserId == user.Id && e.IsReadForm == true).Select(x => x.FormId).ToList();

            return(repository.Search().Where(e => e.UserId == user.Id || formIds.Contains(e.FormId)).Select(x => new FormDetailViewModel()
            {
                CreatedDateTime = x.CreatedDateTime,
                Description = x.Description,
                FormDetailsTypeId = x.FormDetailsTypeId,
                FormId = x.FormId,
                Id = x.Id,
                ModifiedDateTime = x.ModifiedDateTime,
                Name = x.Name,
                Title = x.Title,
                UserId = x.UserId,
                IsRequired = x.IsRequired,
                FormDetailsType = new FormDetailTypeViewModel()
                {
                    Id = x.FormDetailsType.Id,
                    Name = x.FormDetailsType.Name
                }
            }));
        }
Beispiel #5
0
        public IQueryable <FormUserAuthorizationViewModel> Search()
        {
            var formIds = formUserAuthorizationRepository.Search().Where(e => e.UserId == user.Id && e.IsReadForm == true).Select(x => x.FormId).ToList();

            return(repository.Search().Where(e => e.UserId == user.Id || formIds.Contains(e.Id)).Select(item => new FormUserAuthorizationViewModel()
            {
                Id = item.Id,
                FormId = item.FormId,
                IsCreateData = item.IsCreateData,
                IsReadData = item.IsReadData,
                IsUpdateData = item.IsUpdateData,
                IsDeleteData = item.IsDeleteData,
                IsCreateForm = item.IsCreateForm,
                IsDeleteForm = item.IsDeleteForm,
                IsReadForm = item.IsReadForm,
                IsUpdateForm = item.IsUpdateForm,
                UserId = item.UserId,
                CreatedDateTime = item.CreatedDateTime,
                ModifiedDateTime = item.ModifiedDateTime,
                AspNetUser = new AspNetUserViewModel()
                {
                    Id = item.AspNetUser.Id,
                    Email = item.AspNetUser.Email
                },
                Form = new FormViewModel()
                {
                    Description = item.Form.Description,
                    Id = item.Form.Id,
                    CreatedDateTime = item.Form.CreatedDateTime,
                    ModifiedDateTime = item.Form.ModifiedDateTime,
                    Name = item.Form.Name,
                    UserId = item.Form.UserId,
                    PublishUrl = item.Form.PublishUrl
                }
            }));
        }
        public IQueryable <ValueDetailViewModel> Search()
        {
            var formIds = formUserAuthorizationRepository.Search().Where(e => e.UserId == user.Id && e.IsReadData == true).Select(x => x.FormId).ToList();

            return(repository.Search().Where(e => e.UserId == user.Id || formIds.Contains(e.ValueId) || e.Value1.Form.IsPublic == true).Select(x => x.ToViewModel()));
        }