Example #1
0
        public string GetAccessTypeForField(GetForFieldPropertyParams dto)
        {
            var roleId = _userProvider.GetCurrentUser().RoleId;

            var forEntity = Enum.Parse <FieldPropertiesForEntityType>(dto.ForEntity, true);

            int state = forEntity == FieldPropertiesForEntityType.Shippings || forEntity == FieldPropertiesForEntityType.RoutePoints
                ? (int)Enum.Parse <ShippingState>(dto.State, true)
                : (int)Enum.Parse <OrderState>(dto.State, true);

            var fieldMatrixItem = _dataService.GetDbSet <FieldPropertyItem>()
                                  .Where(x => x.ForEntity == forEntity &&
                                         x.FieldName == dto.FieldName &&
                                         x.State == state &&
                                         (x.RoleId == roleId || x.RoleId == null))
                                  .OrderBy(x => x)
                                  .FirstOrDefault();

            var accessType = fieldMatrixItem?.AccessType ?? FieldPropertiesAccessType.Show;

            return(accessType.ToString().ToLowerFirstLetter());
        }
        public IActionResult GetForField([FromBody] GetForFieldPropertyParams dto)
        {
            var accessType = fieldPropertiesService.GetAccessTypeForField(dto);

            return(Ok(new { accessType }));
        }